Fetching dynamic data from my own Server API on ca...
# support
z
I'd like to make a request to my own server URL when the call starts, so I can immediately have my dynamic variables set for the remainder of the call, and can reference them throughout. What's the best way to go about accomplishing this? Very similar to how you might fetch and set data when a component mounts in React. I'd like to do the same here, conceptually, with my inbound phone call.
v
@Zach Sweedler To achieve this, you can set up a webhook that triggers when a call starts. This webhook would make a request to your server URL, fetching the necessary dynamic variables and configurations for the call. You can then store this information in the call context, making it available throughout the call session. Here's a high-level overview of the steps you would take: 1. **Configure a Webhook**: Set up a webhook in your VAPI application that listens for the
call.start
event. 2. **Server Endpoint**: Ensure your server has an endpoint ready to handle requests from the webhook and return the necessary data. 3. **Fetch Configuration**: When the call starts, the webhook will make a request to your server's endpoint. 4. **Store Variables**: Once the data is fetched, store it in the call context so that it's accessible throughout the call. 5. **Reference Variables**: Use the stored variables as needed during the call. Would you like assistance in setting up the webhook or any other part of this process?
You can continue this conversation by mentioning me in the message.
z
@Vapi Documentation on configuring the webhook?
v
@Zach Sweedler I'm here to help guide you through the process of configuring a webhook for your VAPI application. While I can't provide you with actual documentation, I can certainly explain the steps you need to take: 1. **Define the Webhook Endpoint on Your Server**: Create an endpoint on your server that is capable of handling POST requests. This endpoint will receive data from VAPI when a call starts. 2. **Secure Your Endpoint**: It's important to secure your endpoint, typically using HTTPS and possibly a secret token that validates the incoming requests are from VAPI. 3. **Configure the Webhook in VAPI**: Within your VAPI application, you'll need to specify the URL of the endpoint you just created. You'll also need to specify the events that should trigger the webhook, such as
call.start
. 4. **Handle Incoming Data**: When your endpoint receives a request, it should process the data accordingly and return the dynamic variables you need for the call. 5. **Test Your Webhook**: Make sure to test your webhook thoroughly to ensure it's triggered as expected and that your server handles the requests correctly. If you need more detailed instructions or have specific questions about any of these steps, please let me know!
z
@Vapi for "Configure the Webhook in VAPI", is this possible to do on the dashboard?
v
@Zach Sweedler Yes, configuring a webhook in VAPI is typically done through the platform's dashboard. While I don't have the exact details of the VAPI dashboard, the general process would be as follows: 1. **Log in to the VAPI Dashboard**: Use your credentials to access the dashboard. 2. **Navigate to the Webhooks Section**: Look for a section in the dashboard that deals with webhooks or event handling. 3. **Create a New Webhook**: There should be an option to create a new webhook. Click on this to start the configuration process. 4. **Set Webhook Details**: Enter the URL of your server endpoint that you want VAPI to call. You may also need to specify the events that should trigger the webhook, such as
call.start
. 5. **Save and Activate Webhook**: After entering the necessary details, save the webhook configuration. It may need to be activated or enabled if it's not done automatically upon saving. 6. **Test the Webhook**: Ensure that the webhook is working correctly by initiating a call and checking if your server endpoint receives the request. If you're unable to find the option to configure webhooks on the dashboard or if you need more specific guidance, please refer to the VAPI documentation or ask support for more info on this.
z
There is no webhooks section...
@Vapi Can I use a system variable like the phone number the call is from inside function.parameters.properties value?
v
@Zach Sweedler In VAPI, system variables such as the phone number the call is from can often be used within the parameters of a function. These variables are typically available as part of the call context and can be referenced accordingly. For example, if you have a function that requires the caller's phone number as a parameter, you could pass it like this:
Copy code
json
{
  "functionName": {
    "parameters": {
      "phoneNumber": "{{caller_number}}"
    }
  }
}
In this example,
{{caller_number}}
would be replaced with the actual phone number of the caller when the function is executed. Please note that the exact syntax for referencing system variables can vary depending on the VAPI platform you are using. If you need the exact method to reference a system variable in function parameters for your specific VAPI platform, please ask support for more info on this.
z
@User is there a from and to system variable provided by default?
s
check vapi docs for assistantOverrides and server event request assistant. your issue will be resolved.
10 Views