How to get call ID using the SDK
# support
n
Is there any way to get the ID of a call using the SDK? I am adding Vapi to a web app for AI conversations and I need to know the ID of the conversation that is happening so that I can use the Get Call endpoint after the call to get the messages of the call after it has completed. Here is the flow: User starts a Vapi call in their browser User and assistant have AI conversation User ends call Web application makes a request to the Vapi API Get Call endpoint (https://docs.vapi.ai/api-reference/calls/get-call) and passes in API key and call ID Web application receives the response from Vapi Get Call that contains the call's messages. In order to complete step 4, we need the call ID of the call that the user was on. How can we get this?
v
@NickMenendez Certainly! To obtain the call ID during an ongoing Vapi call, you can utilize the event system that Vapi provides. When a call is initiated, Vapi typically sends out events with relevant information about the call, including the call ID. Here's a general approach to capture the call ID: 1. Listen for the call event that is triggered when a call starts. This event usually contains the call object. 2. Extract the call ID from the call object provided in the event data. 3. Store the call ID in your web application's state or database for later retrieval. 4. Use the stored call ID to make a request to the Vapi API Get Call endpoint after the call has ended. The exact implementation details will depend on how you've integrated Vapi into your web application. If you're using a JavaScript SDK or similar library, there should be an event listener or callback function where you can access the call object. If you need more specific guidance on how to implement this in your application, please provide additional details about your current setup or the SDK you are using, and I'll be happy to assist further!
You can continue this conversation by mentioning me in the message.
@NickMenendez Sweet. Have a great day!
@Vapi Sweet. Have a great day!
13 Views