Dynamic variables not loading in time during inbou...
# support
t
Hey, I’m having an issue with dynamic variables not loading in time during inbound calls. Here’s what’s happening: • I have a Vapi assistant with {{name}}, {{petName}}, and {{petType}} set up in the first message. • I’m using the “Server URL” (not a tool) to trigger an n8n webhook on call start. • In the webhook, I query Supabase for the customer and pet data based on customer.number, then respond with a Respond to Webhook node like this: { "assistantId": "xxxxx", "assistantOverrides": { "variableValues": { "name": "John", "petName": "Zena", "petType": "cat" } }, "customer": { "number": "+19782221234" }, "phoneNumberId": "xxxxxx" } Everything looks fine in the webhook response logs, and the data is correctly passed back. BUT… the assistant still starts the call by saying “Hi, thanks for calling” instead of using the name. However, when I manually trigger the call via API (using the same values), the assistant says the name correctly. It seems like the webhook response is arriving too late during inbound calls. Is there any way to delay the first message until the webhook returns the assistantOverrides? Or am I missing something in the config? Would appreciate any guidance!
v
Hi there! 👋 I understand you're having an issue with dynamic variables not loading in time during inbound calls, causing your assistant to use a generic greeting instead of the customer's name. I can't see your specific configuration beyond what you've shared, but I can definitely help with ways to delay the first message until your webhook returns the assistantOverrides. Based on the information I found, here are several approaches you can try: 1. Use
startSpeakingPlan.waitSeconds
to add a delay before the assistant starts speaking:
Copy code
javascript
const assistant = {
  firstMessageMode: 'assistant-speaks-first',
  startSpeakingPlan: {
    waitSeconds: 2 // Waits 2 seconds before speaking
  }
  // ... other configurations
};
This will add a 2-second delay before the assistant starts speaking, which might give your webhook enough time to return the data ([source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343915991670853654)). 2. Set
assistantOverrides.maxDurationSeconds
to make the assistant remain silent for a specific period:
Copy code
javascript
assistantOverrides: {
  maxDurationSeconds: 5 // Remains silent for 5 seconds
}
This ensures the assistant remains silent for the specified duration, giving your webhook time to return ([source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1335807780287676456)). 3. Set
firstMessageMode
to
assistantWaitsForUser
to make the assistant wait for user input before responding:
Copy code
javascript
const assistant = {
  firstMessageMode: 'assistantWaitsForUser',
  // ... other configurations
};
This makes the assistant wait for the user to speak first ([source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1305065394662408192)).
4. Use a static first message that doesn't require dynamic variables, then use the variables in subsequent messages after your webhook has returned the data ([source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1339303957675245669)). 5. Use Custom Endpointing Rules to instruct the pipeline to pause for user input for a specified duration ([source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1335807780287676456)). Would any of these approaches work for your use case? Or do you need more details on implementing one of these solutions? Sources: - [Discord Thread about startSpeakingPlan.waitSeconds](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343915991670853654) - [Discord Thread about assistantOverrides.maxDurationSeconds](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1335807780287676456) - [Discord Thread about firstMessageMode](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1305065394662408192) - [Discord Thread about static first message](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1339303957675245669)
k
Hey! To help track down this issue, could you share: - The call ID - What response you expected to get - What response you actually got instead This would really help us figure out what went wrong!
t
Hi, thanks for help me!
Here’s the info you asked for: • Call ID: 0561527a-77be-47f2-ad7f-9826134bb06b • What I expected: I expected the assistant to greet the caller using the dynamic variable I provided ({{name}}). For example: “Hi Tiago Bardini, thanks for calling! My name is Pink…” • What I actually got: The assistant ignored the {{name}} variable and said: “Hi, thanks for calling! My name is Pink…” It seems like the dynamic variable was not resolved in time or not injected correctly, even though I returned it via Respond to Webhook inside n8n like this: { "assistantId": "a386d462-a987-4c79-9539-89e8f56a0528", "assistantOverrides": { "variableValues": { "name": "Tiago Bardini", "petName": "Zena", "petType": "cat" } }, "customer": { "number": "+19786487075" }, "phoneNumberId": "2cef9895-a1b1-47e5-9c06-f8d83ea4556f" } I’m using the Server URL (not tool) method, with a webhook that queries Supabase and responds before the assistant speaks. I also tried using startSpeakingPlan.waitSeconds = 5 and firstMessageMode = assistant-waits-for-user but it didn’t help. Let me know if there’s anything I’m missing or if this might be a bug. Thanks again!
k
Tiago Bardini, Your dynamic variables are not being applied because your assistant overwrite is empty. That's because your phone number used doesn't have a server URL; it's using an assistant assigned to it. You can check your server for the logs that your server is not getting requests (server message of type 'assistant request'). I suggest you remove the assistant ID from your phone number, assign a server URL to your phone number, and then VAPI will trigger an assistant request server message to your server URL at this time. You can return the dynamic variables as passed off as part of assistant overwrites.
t
This is very confuse! can you provide documetation, something i cant take a look please. I am trying to handle inbound calls using Twilio and Vapi, but I’m facing issues with sending dynamic assistantOverrides when the call hits the Vapi webhook. My Twilio number is currently configured to point to Vapi’s webhook: https://api.vapi.ai/twilio/inbound_call I use N8N to process incoming calls. I successfully fetch customer and pet data from Supabase based on the caller’s number. This dynamic data works perfectly when I initiate outbound calls using the Vapi API, including the assistantOverrides like: • name: Tiago Bardini • petName: Zena • petType: cat However, for inbound calls, even though I’m returning a proper webhook response, the assistantOverrides are not being applied. I also tried sending XML responses and different formats, but it either loops or fails silently. I’m now considering using a transient assistant to apply these dynamic values. Could you clarify: 1. What is the recommended way to inject assistantOverrides for inbound Twilio calls? 2. Is creating a transient assistant the correct approach for this use case? I’d appreciate any insights or examples that could help me get this working properly. Thank you!
t
Thank you!
k
Marking this ticket as Solved ✅
3 Views