tscdl
03/25/2025, 1:03 PMVapi Support Bot
03/25/2025, 1:05 PMCalledVia
and ForwardedFrom
parameters from Twilio webhooks. Let me explain what I found and how you can handle this.
According to the information I found, Vapi's implementation only extracts specific parameters from the Twilio webhook payload, including Caller
, CallSid
, To
, and From
, but not CalledVia
or ForwardedFrom
. Here's what the code looks like:
python
def twilio_inbound_call(request_body):
"""Receive Twilio incoming call webhook and forward it to Vapi."""
Caller = request_body.get("Caller", "")
CallSid = request_body.get("CallSid", "")
To = request_body.get("To", "")
From = request_body.get("From", "")
Your approach is correct - you'll need to intercept the Twilio webhook on your server first and then pass the necessary information to Vapi. There are a few ways to do this:
1. **Set up your own webhook endpoint**: Instead of auto-registering your Twilio number with Vapi, you can [set up your own webhook endpoint](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343397177182912553), process the call as needed (capturing the CalledVia
and ForwardedFrom
parameters), and then forward to Vapi using TwiML when required.
2. **Pass data using assistantOverrides**: You can use the assistantOverrides
parameter with variableValues
to pass the forwarding information:
javascript
vapiInstance = vapiSDK.run({
apiKey: apiKey,
assistant: assistant,
config: buttonConfig,
assistantOverrides: {
variableValues: {
calledVia: "yourCalledViaValue",
forwardedFrom: "yourForwardedFromValue"
}
}
});
This way, the forwarding information will be available when Vapi calls your webhook.
Is there anything specific about implementing this approach that you'd like me to clarify further?
Sources:Vapi Support Bot
03/25/2025, 1:05 PMVapi Support Bot
03/25/2025, 1:05 PMCalledVia
and ForwardedFrom
parameters from Twilio webhooks.
Based on the information I've found, you're correct in your assumption. Vapi does not appear to directly capture the CalledVia
parameter from Twilio webhooks. For the ForwardedFrom
parameter, while Vapi interacts with Twilio webhooks and extracts some parameters (like Caller
, CallSid
, To
, and From
), there's no clear indication that ForwardedFrom
is captured by default.
According to the information I found, the api.vapi.ai/twilio/inbound_call
endpoint captures parameters such as:
- AccountSid
- Caller
- CallSid
- To
- From
But it doesn't explicitly capture CalledVia
or ForwardedFrom
[source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343574701909344297).
Your approach of intercepting the Twilio webhook on your server first and then injecting these values into the metadata prop (which is an object with 3 properties) seems to be the right direction. This would allow you to capture these parameters before they reach Vapi and ensure you have access to the originally intended target phone number.
Is there anything else you'd like to know about handling these Twilio parameters with Vapi?
Source:
- [Discord Thread about Twilio Parameters](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343574701909344297)Vapi Support Bot
03/25/2025, 4:48 PMtscdl
03/25/2025, 4:50 PMVapi Support Bot
03/26/2025, 10:25 AMKyle Brunker
03/26/2025, 2:44 PMtscdl
03/26/2025, 5:51 PMKyle Brunker
03/29/2025, 11:14 AMtscdl
03/31/2025, 6:24 AMKyle Brunker
03/31/2025, 1:27 PM