Widget Chat API System Prompt Overriding
# support
r
Question 1: Do the Widget Chat APIs support a system prompt field? How can we add a prompt in the Widget Chat API to tell the assistant it’s text chat, not a voice call? Scenario We want to reuse the same assistant prompt for both voice assistants and widget chatbot (through calling the Widget Chat API):
Copy code
curl -X POST https://api.vapi.ai/chat \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "assistantId": "your-assistant-id",
    "input": "Explain how to set up API authentication in detail",
    "stream": true
  }'
Right now the assistant replies as if it’s in a voice call. We want to add an override (or maybe additional is better) system prompt to make sure it knows this is text chat. Question 2: We’re also considering Pass Dynamic Variables so the assistant can detect the mode in text chat. For example:
Copy code
You are a helpful {{chatMode}} customer support agent

In the Widget Chat API we can set:

"assistantOverrides": {
  "variableValues": {
    "chatMode": "text chat"
  }
}
So the question is: if we only modify the prompt in the front-end GUI for the voice assistant, how can we do the same variable substitution so the voice assistant knows it’s in voice mode?
v
To indicate the mode (e.g., "text chat") in your Widget Chat API, use dynamic variables in your assistant's prompt and set them via
assistantOverrides.variableValues
in your API call.
For example:
Copy code
json
{
  "assistantId": "your-assistant-id",
  "input": "Explain how to set up API authentication in detail",
  "assistantOverrides": {
    "variableValues": {
      "chatMode": "text chat"
    }
  }
}
Make sure your assistant's prompt includes
{{chatMode}}
for this to take effect.
[See documentation](https://docs.vapi.ai/chat/quickstart#pass-variables-in-your-chat-request) Sources: - [Chat quickstart – Pass variables in your chat request](https://docs.vapi.ai/chat/quickstart#pass-variables-in-your-chat-request) - [Assistants: Dynamic Variables](https://docs.vapi.ai/assistants/dynamic-variables)
r
@Vapi Support Bot How do I setup the dynamic variables in Vapi dashboard then?
v
You cannot set dynamic variable values directly in the Vapi dashboard. Instead, reference your variables in the prompt (e.g.,
{{chatMode}}
) within the dashboard, and then set their values in your API call using
assistantOverrides.variableValues
. Example:
Copy code
json
{
  "assistantId": "your-assistant-id",
  "input": "Hello!",
  "assistantOverrides": {
    "variableValues": {
      "chatMode": "text chat"
    }
  }
}
Set the variable value in your API request, not in the dashboard UI. [See documentation](https://docs.vapi.ai/assistants/dynamic-variables) Source: - [Assistants: Dynamic Variables](https://docs.vapi.ai/assistants/dynamic-variables)
c
Can you provide an example of how you would want the assistant to respond if it was on a phone call in comparison to how it responds during a call?
2 Views