Passing user's information to assistant before sta...
# support
a
how we can pass the data before even calling Connects while keeping the assistant ID the same? As I am able to pass the data to assistant using "assistant-request" event. But the issue is, that assistant doesn't have a fixed id and I need a fixed id because I want to transfer my call to the same bot I created using "assistant-request" event/
c
Hi Ahmer, To pass a user's information to an assistant using a fixed assistant ID before starting a call, you'll need to utilize dynamic variables. Here are the steps to implement this: 1. Prepare Your JSON Payload: - Use
assistantId
for your fixed assistant. - Include
assistantOverrides
with
variableValues
to set the personalized data. Example:
Copy code
json
   {
     "assistantId": "your-assistant-id",
     "assistantOverrides": {
       "variableValues": {
         "name": "John",
         "accountType": "Premium",
         "joinDate": "2021-06-15"
       }
     },
     "customer": {
       "number": "+123456789"
     },
     "phoneNumberId": "your-phone-id"
   }
2. Dynamic Variables in Prompts: - Ensure that prompts in your assistant configuration use dynamic variable syntax like
{{name}}
. - For instance, a prompt could be: "Hello, {{name}}! Thank you for being a {{accountType}} member since {{joinDate}}." 3. Send the Request: - Make an API call to the
/call/phone
endpoint with the JSON payload. 4. Ensure Server Configuration: - Check that your server responds within the required time (7.5 seconds). - Confirm dynamic variable placeholders are correctly set up in your assistant configuration. For detailed information, you can refer to [personalization with user information documentation](https://docs.vapi.ai/assistants/personalization) and [using dynamic variables](https://docs.vapi.ai/assistants/dynamic-variables).
a
What if I create an Assistant in the Dashboard with dynamic variables? How can I update those variables? I would like to update them before starting the call, so I can retrieve the variable values and include them in the prompt. Also, could you explain the flow of a call? Currently, I’m using the Assistant request feature: when a user calls, I extract their information and pass it into the prompt. The issue is that I’ve connected this bot to a phone number, but I also want to connect it to a web app. Ideally, I’d like to have a single bot for both the web app and phone calls, so that any changes I make to the bot are reflected in both places. Right now, we have separate bots for the web and for phone calls.
c
1. Using Dynamic Variables: You can update variables before starting a call by using the
assistantOverrides
parameter with
variableValues
[1](https://docs.vapi.ai/assistants/dynamic-variables). Here's how:
Copy code
{
  "assistantId": "your-assistant-id",
  "assistantOverrides": {
    "variableValues": {
      "name": "John",
      "customerId": "12345"
    }
  },
  "customer": {
    "number": "+1xxxxxxxxxx"
  },
  "phoneNumberId": "your-phone-id"
}
You can use these variables in your prompts using double curly braces:
{{name}}
,
{{customerId}}
, etc. 2. Using the Same Assistant for Web and Phone: Yes, you can use the same assistant for both web and phone calls! The assistant configuration (prompts, variables, etc.) remains consistent across both channels. You just need to: 3. Set up the assistant in the dashboard 4. Configure it for phone calls by attaching it to a phone number 5. Use the same assistant ID when integrating with your web application You don't need separate bots - any changes made to the assistant will automatically apply to both web and phone interactions. Some default variables are also available automatically, like: -
{{now}}
- Current date/time -
{{date}}
- Current date -
{{customer.number}}
- Customer's phone number
a
I think the confusion is that, in the case of an assistant-request, we don’t have an assistant-id, but we are still receiving the request on the server. In the case of creating an assistant using the Dashboard, how can I update the variables before starting a call using assistantOverrides? How do I know when a person has called, so I can retrieve the customer details and provide them to the assistant override? When I used the Overrides parameter in the prompt, what you are saying is: I should create an assistant in the Dashboard with dynamic variables, then use the assistant-request feature to get the call request. From that call request, I would call the call/phone endpoint with the JSON payload you provided. Could you kindly confirm if this is correct?
c
Hello, The assistant request and variables work: 1. For inbound calls (when someone calls your Vapi number), there are two ways to handle it: - Set a fixed
assistantId
on the phone number configuration - this will always use the same assistant - Leave
assistantId
blank - Vapi will make an "assistant-request" to your server webhook, where you can dynamically return which assistant to use 2. For setting variables, you would need to: a) Create an assistant in the Dashboard with dynamic variables like
{{name}}
in the prompts b) When making a call (outbound) or responding to an assistant-request (inbound), provide the variable values in `assistantOverrides.variableValues`:
Copy code
{
  "assistantOverrides": {
    "variableValues": {
      "name": "John"
    }
  }
}
When you receive an assistant-request webhook on your server, you can: 1. Look up customer details based on their phone number 2. Return an assistant response with the appropriate variable values 3. Vapi will then start the call using that assistant with the provided variables
2 Views