forwardedFrom parameter
# support
e
Twilio sends Vapi a ForwardedFrom parameter when inbound calls come in. I would like to change the assistant based on which phone number is forwarding the call. How can I access this parameter when I receive a webhook associated with a transient assistant?
v
message has been deleted
@Edpreble To access the
ForwardedFrom
parameter when you receive a webhook for an inbound call, you would typically extract it from the request body that Twilio sends to your webhook URL. The exact method to retrieve this parameter depends on the programming language and framework you're using to handle the webhook. Here's a general approach you can follow: 1. Set up your webhook endpoint to receive POST requests from Twilio when an inbound call occurs. 2. In the handler for this endpoint, parse the incoming request to extract the
ForwardedFrom
parameter. This is usually part of the POST data that Twilio sends. 3. Once you have the
ForwardedFrom
value, you can use it to determine which assistant should handle the call. For example, in a Node.js Express application, you might have something like this:
Copy code
javascript
app.post('/inbound-call', (req, res) => {
  const forwardedFrom = req.body.ForwardedFrom;
  // Logic to select the appropriate assistant based on the 'forwardedFrom' value
});
If you need to perform this action within the context of VAPI, you would need to ensure that your webhook processing code is set up to handle this logic and then use the appropriate VAPI functions to direct the call to the correct assistant. If you have any specific questions about how to implement this in your code or need further assistance with VAPI functions, please let me know!
You can continue this conversation by mentioning me in the message.
e
Vapi does not appear to deliver the forwardedFrom parameter in the JSON payload. How can I get this parameter delivered in the payload?
Hoping for a response on this.
Is anybody seeing this?
Still waiting for a response.
@Vapi I still need help
v
@Edpreble I apologize for the delay. If the
ForwardedFrom
parameter is not being delivered in the JSON payload by default, you may need to configure your Twilio webhook to include this parameter when calls are forwarded. Here's what you can do: 1. Log in to your Twilio account and go to the phone number configuration page. 2. Find the phone number that's receiving the forwarded calls. 3. Look for the section where you set up your webhook URL for incoming calls. 4. Ensure that you have selected the "HTTP POST" method for the webhook to receive data from Twilio. 5. If there are any advanced settings or options to include additional parameters, make sure they are configured correctly. If after checking these settings the
ForwardedFrom
parameter is still not included, you may need to reach out to Twilio support for further assistance as this could be an issue with how Twilio is sending the data to your webhook. Please let me know if you need further assistance or if there's anything else I can do to help!
e
That didn't solve the problem. VAPI is not sending the forwardedFrom parameter in the JSON payload. Please help
s
@Edpreble you can try this out if twilio sends forwardedFrom.
Copy code
py
...

@app.post("/twilio/inbound_call")
async def receive_call_data(
    AccountSid: str = Form(...),
    ...,
    ForwardedFrom: Optional[str] = Form(None)  # Added to capture the forwarding number
):
    # Prepare the payload for VAPI
    payload = {
        "phoneNumberId": "your-phone-number-id",
        "phoneCallProviderBypassEnabled": True,
        "customer": {
            "number": Caller
        },
        "assistantId": "your-assistant-id",
        "assistantOverrides": {
            "metadata": {
                "forwarded_from": ForwardedFrom  # Pass the ForwardedFrom as metadata
            }
        }
    }

    # Make the request to VAPI
    response = requests.post(
        "https://api.vapi.ai/call",
        json=payload,
        headers={
            "Content-Type": "application/json",
            "Accept": "application/json",
            "Authorization": f"Bearer {api_key}"
        }
    )

    # Handle the response
    result = response.json()
    return result["phoneCallProviderDetails"]["twiml"]
Complete Code Without Forwarded From, add it as shared in the example. https://github.com/VapiAI/advanced-concepts-phone-call-provider-bypass/blob/master/app/main.py
Basically idea is to get the call on your server, extract the forwarded from and then pass it to the Vapi.
e
Thank you. For clarification, I replace the VAPI webhook URL in Twilio with the URL of my own server, extract the forwardedFrom info then send the call to the VAPI webhook?
I sent the call to my webhook in Make.com and I see that Twilio passes "CalledVia" and "ForwardedFrom" parameters to me. The values are identical. However I don't know what to do with the information. I tried passing the call to Vapi from Make.com but had no success. My assistant is a transient assistant so the instructions in the "advance-concepts" document didn't make sense. Ultimately, I'd like the call to go from Twilio -> Vapi -> Make.com webhook -> Vapi (with transient assistant JSON payload that includes instrucions based on the value of the "CalledVia" or "ForwardedFrom" value). Please advise.
@User please advise
s
@Edpreble can you share a detailed loom video of your current setup with phone-call-provider-bypass-enabled?