From b6bacc65b3ff3df4bd6db2c0c21572bf62b15a96 Mon Sep 17 00:00:00 2001 From: Chiranjeet Mishra Date: Wed, 14 Oct 2026 03:44:56 +0000 Subject: [PATCH 1/2] docs: use vapi.send add-message instead of nonexistent vapi.addMessage @vapi-ai/web 2.7.1 has no addMessage method; context is injected with vapi.send({ type: 'add-message', message, triggerResponseEnabled? }). --- fern/tools/client-side-websdk.mdx | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/fern/tools/client-side-websdk.mdx b/fern/tools/client-side-websdk.mdx index 354de9a12..5e21f99a2 100644 --- a/fern/tools/client-side-websdk.mdx +++ b/fern/tools/client-side-websdk.mdx @@ -12,7 +12,7 @@ Use the Web SDK to handle tool-calls entirely on the client. This lets your assi **In this guide, you'll learn to:** - Define a client-side tool with the Web SDK - Receive and handle `tool-calls` events on the client -- Inject extra context during a call with `addMessage` +- Inject extra context during a call with an `add-message` message Client-side tools cannot send a tool "result" back to the model. If the model must use the output of a tool to continue reasoning, implement a server-based tool instead. See: Server-based Function tools. @@ -32,7 +32,7 @@ npm install @vapi-ai/web 2. Start a call with your tool defined in the model.tools array and subscribe to clientMessages: ['tool-calls']. 3. Listen for message.type === 'tool-calls' and perform the desired UI update. No response is sent back to the model. -4. (Optional) Inject context mid-call using vapi.addMessage(...). +4. (Optional) Inject context mid-call using `vapi.send({ type: 'add-message', ... })`. ## Complete example (React + Web SDK) @@ -264,19 +264,25 @@ export default App; ## Inject data during the call -Use addMessage to provide extra context mid-call. This does not return results for a tool; it adds messages the model can see. +Send an add-message message with vapi.send to provide extra context mid-call. This does not return results for a tool; it adds messages the model can see. Set triggerResponseEnabled to true if the assistant should respond to the new message right away. ```ts // Inject system-level context -vapi.addMessage({ - role: 'system', - content: 'Context: userId=123, plan=premium, theme=dark', +vapi.send({ + type: 'add-message', + message: { + role: 'system', + content: 'Context: userId=123, plan=premium, theme=dark', + }, }); // Inject a user message -vapi.addMessage({ - role: 'user', - content: 'FYI: I switched to the settings tab.', +vapi.send({ + type: 'add-message', + message: { + role: 'user', + content: 'FYI: I switched to the settings tab.', + }, }); ``` @@ -289,7 +295,7 @@ If you need the model to consume tool outputs (e.g., fetch data and conti - **Client-only execution**: Omit the server URL to run tools on the client. - **One-way side effects**: Client tools do not send results back to the model. - **Subscribe to events**: Use clientMessages: ['tool-calls'] and handle message.type === 'tool-calls'. -- **Add context**: Use vapi.addMessage to inject data mid-call. +- **Add context**: Use vapi.send with an add-message message to inject data mid-call. ## Next steps From b75baf41981201988b1775494de243089b38a999 Mon Sep 17 00:00:00 2001 From: Stephen Smith Date: Wed, 14 Oct 2026 10:38:57 -0700 Subject: [PATCH 2/2] Fix triggerResponseEnabled default wording Co-Authored-By: Claude Opus 5.5 --- fern/tools/client-side-websdk.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fern/tools/client-side-websdk.mdx b/fern/tools/client-side-websdk.mdx index 5e21f99a2..377fc21ab 100644 --- a/fern/tools/client-side-websdk.mdx +++ b/fern/tools/client-side-websdk.mdx @@ -264,7 +264,7 @@ export default App; ## Inject data during the call -Send an add-message message with vapi.send to provide extra context mid-call. This does not return results for a tool; it adds messages the model can see. Set triggerResponseEnabled to true if the assistant should respond to the new message right away. +Send an add-message message with vapi.send to provide extra context mid-call. This does not return results for a tool; it adds messages the model can see. By default triggerResponseEnabled is set to true and the assistant should respond to the new message right away. ```ts // Inject system-level context