Twilio Metadata needed
# support
t
Hi there, I need to pipe in the originally intended target phone number in case a call was forwarded. Twilios webhook POSTs contain the following parameters representing the number: api.vapi.ai/twilio/inbound_call: CalledVia: String ForwardedFrom: String api.vapi.ai/twilio/status: ForwardedFrom: String Iยดve reads all the docs, I think, am I assuming correctly, that you do not capture these values at the Vapi layer? Couldยดnt see them in you serverURL / webbhook logs. This means, I have to catch the Twilio initiation webhook call on our server first and "inject" the values into, probably, the metadata prop? Thanks a lot! ๐Ÿ‘‹ Timo
v
Hi Timo! ๐Ÿ‘‹ You're right - based on the information I found, Vapi does not automatically capture the
CalledVia
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:
Copy code
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:
Copy code
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:
- [Discord conversation about Twilio inbound call processing](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343574701909344297) - [Discord conversation about intercepting Twilio calls](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343397177182912553) - [Discord conversation about using assistantOverrides with variableValues](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1339495894801711186)
Hi Timo! ๐Ÿ‘‹ I understand you're looking to capture the originally intended target phone number when a call is forwarded, specifically the
CalledVia
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)
v
Message marked as helpful by @tscdl! ๐ŸŽ‰
t
Thank you. I wonder, when using the assistantOverrides-approach, is it still possible to have to call-agent-initiation to wait for the incoming override values? I imagine it could get messy if for some reason the overrides-delivering server is too slow to have delivered the data on call begin.
v
Message marked as helpful by @tscdl! ๐ŸŽ‰
k
hey @tscdl checking if this is resolved for you?
t
Not really, the last question from 5:50pm is still open.
k
Oh yes, you're right. We don't set them by default, and you'll be given a total of 7.5 seconds to provide these variable values when an request comes to us over your server url. If you're getting this in time, it's definitely good.
t
Thanks very much. Can I change to solved status myself?
k
Marking this ticket as Solved โœ