precall webook for data
# support
g
How can I send dynamic pre-call data to Vapi’s assistant, like customer details, using an API or webhook, similar to Bland AI’s pre-call webhook setup?
v
Hi there! 👋 While I don't have complete details about Bland AI's specific pre-call webhook setup, I can definitely help you with how to send dynamic pre-call data to Vapi's assistant using APIs and webhooks! Here are several approaches you can use to send dynamic data to Vapi before a call: ## 1. Set Up Your Own Webhook Endpoint You can create your own webhook endpoint to intercept calls before they reach Vapi:
Copy code
javascript
// Your webhook endpoint
@app.post("/twilio/inbound_call", response_class=PlainTextResponse)
async def receive_call_data(
        AccountSid: str = Form(...),
        // other parameters
        ToZip: Optional[str] = Form(None)
):
    call_data = CallData(
        AccountSid=AccountSid,
        // other data
        ToZip=ToZip
    )

    r = requests.post("https://api.vapi.ai/call", json={
        "phoneNumberId": "your-phone-number-id",
        "phoneCallProviderBypassEnabled": True,
        "customer": {
            "number": call_data.Caller
        },
        "assistantId": "your-assistant-id"
    }, headers={
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Authorization": f"Bearer {api_key}"
    })
    result = r.json()
    return result["phoneCallProviderDetails"]["twiml"]
This approach allows you to process the call as needed and then forward it to Vapi using TwiML when required, [according to information found in Discord](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343397177182912553). ## 2. Use
assistantOverrides
with
variableValues
You can pass dynamic variables to Vapi using the
assistantOverrides
parameter with the
variableValues
object:
Copy code
json
{
  "variableValues": {
    "name": "CustomerName",
    "accountId": "12345",
    "otherData": "value"
  }
}
This allows you to set variables dynamically for each call, [as mentioned in this Discord thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1335054553250533439). ## 3. Use Vapi's API Endpoints Vapi provides API endpoints for creating and updating calls that can be used to send pre-call data:
Copy code
bash
curl -X POST 'https://api.vapi.ai/call' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
  "phoneNumberId": "your-phone-number-id",
  "phoneCallProviderBypassEnabled": true,
  "customer": { 
    "number": "customer-phone-number" 
  },
  "assistantId": "your-assistant-id",
  "assistantOverrides": {
    "variableValues": {
      "customerName": "John Doe",
      "accountStatus": "Premium"
    }
  }
}'
## 4. Vapi Web SDK Method If you're using the Vapi Web SDK, you can override assistant settings or set template variables:
Copy code
javascript
const assistantOverrides = {
  variableValues: {
    name: "Alice",
    accountType: "Premium",
    lastPurchase: "2025-03-15"
  },
};

vapi.start("your-assistant-id", assistantOverrides);
[According to Vapi's Web SDK documentation](https://docs.vapi.ai/sdk/web), this is a straightforward way to pass dynamic data. Is there a specific implementation approach you're interested in exploring further? Sources: - [Discord Thread on Intercepting Calls](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343397177182912553) - [Discord Thread on Using assistantOverrides](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1335054553250533439) - [Vapi Web SDK Documentation](https://docs.vapi.ai/sdk/web) - [Discord Thread on Webhook Configuration](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336345690393149452)
g
@Vapi so no direct way?
/help no direct way?
p
a gentle reminder to continue this thread.
u
@Shubham Bajaj how to enable an agent to send an assistant-request webhook? I don't see an option in the Messaging tab for an agent https://cdn.discordapp.com/attachments/1360269517212749945/1361324751577944254/image.png?ex=67fe57f8&is=67fd0678&hm=7dfbd26d6c0d0bdf4da354566dd03aa9ca6b081be5ecf414da84a05f0e362546&
p

4 Views