Way to get interview `id` from client component
# support
n
after a call finishes I want to get back the transcript and toss it into a database. Seems the best way to do this is to give the server-sdk the ID, have it look up the call, and then process the data. But I can't figure out a way for the client to give the server-sdk the ID, let alone access the ID at all. How can the client access the call ID?
v
@nearLucid To enable the client to access the call ID and provide it to the server-sdk for processing, you can implement a mechanism where the call ID is returned to the client as part of the call metadata. When the call is initiated or completed, the server can send a message to the client containing the call ID. Here's a general approach you can take: 1. When a call is initiated, the server generates a unique call ID and associates it with the call session. 2. At the end of the call, the server includes the call ID in the
end-of-call-report
message. 3. The client receives the
end-of-call-report
message and extracts the call ID from it. 4. The client then sends the call ID to the server-sdk, which can use it to look up the call and process the data accordingly. 5. The server-sdk retrieves the call transcript and stores it in the database. If you have a specific API or method you're using to handle calls, please provide more details, and I can give you a more tailored solution. If you need the server to perform an action based on the
end-of-call-report
, please let me know the specifics, and I can guide you on how to proceed.
You can continue this conversation by mentioning me in the message.
Got it. Tagging @User for additional help.
n
@Vapi how do I end the call without killing the vapi client? if I use vapi.current.stop(), it'll become null before I can listen for the message
v
@nearLucid To end the call without terminating the VAPI client instance, you should use the
say
method with the
endCallAfterSpoken
parameter set to
true
. This will allow you to gracefully end the call with a final message, and the VAPI client will remain active to handle any last events or messages. Here's how you can do it:
Copy code
javascript
vapi.say("Thank you for calling, goodbye!", true);
This method will play the specified message to the user and then end the call. The VAPI client instance (
vapi
) will still be available for you to listen for any final events or to perform any cleanup actions before the client itself is disposed of. If you need to perform actions after the call has ended, make sure to set up your event listeners before ending the call. This way, you can capture the
callEnded
event or any other relevant information you need.
n
@Vapi after what method is the end of call report sent?
v
@nearLucid The end-of-call report is typically sent after the call has been terminated using a method that ends the call, such as
hangup
or any other method provided by the API that results in the call ending. Once the call has ended for any reason (such as the user hanging up, the call timing out, or being programmatically ended by the developer), the VAPI client or server will trigger the end-of-call report. If you're using a specific Voice API, the end-of-call report is usually sent automatically by the server as a webhook to the specified callback URL. This happens immediately after the call ends and the
hangup
event is processed. To ensure you receive the end-of-call report, you should set up a webhook listener on your server that is configured to receive POST requests from the Voice API provider. The Voice API provider will then send the end-of-call report to this listener as a POST request with the call details, including the reason the call ended. If you need to know the exact method or event that triggers the end-of-call report in your specific setup, please provide more details about the Voice API you are using, and I can give you a more precise answer.
n
@Vapi what is the hangup method? I only see stop() in the docs
v
@nearLucid If the documentation for the Voice API (VAPI) you are using only mentions a
stop()
method and not a
hangup
method, then
stop()
is likely the method you should use to end the call. The
stop()
method would be responsible for terminating the call session. Here's a general approach to using
stop()
while ensuring you can still listen for the end-of-call report: 1. Set up your event listener for the end-of-call report before calling
stop()
. 2. Call the
stop()
method to end the call. 3. The VAPI client should remain active long enough to receive the end-of-call report. For example:
Copy code
javascript
// Set up the event listener for the end-of-call report
vapi.on('endOfCallReport', (report) => {
    // Process the report here
});

// End the call
vapi.stop();
By setting up the listener before ending the call, you ensure that your client is still listening for the end-of-call report even after the
stop()
method has been called. The VAPI client should not become null immediately after calling
stop()
, allowing for the reception of the final report. If you have any specific requirements or need further clarification on handling the end-of-call report with your VAPI client, please let me know, and I'll be happy to assist you further.
n
@Vapi It doesn't seem like the end of call report is ever being sent after vapi.stop() only a speech update with status of stopped
Copy code
{type: 'speech-update', status: 'stopped', role: 'assistant'}role: "assistant"status: "stopped"type: "speech-update"[[Prototype]]:
v
@nearLucid It appears that the
vapi.stop()
method is designed to stop the current voice interaction, and the event you're receiving (
{type: 'speech-update', status: 'stopped', role: 'assistant'}
) indicates that the speech output from the assistant has been stopped. If you are not receiving an end-of-call report, it could be that the VAPI you are using does not automatically send such a report, or it may require additional configuration to do so. Typically, an end-of-call report would be a feature of the server-side logic, where the server would compile the call data and send a report after the call has ended. Here's what you can do: 1. **Check Documentation**: Review the VAPI documentation to see if there is a specific event or method that is used to generate and send an end-of-call report. 2. **Server-Side Logic**: If the VAPI does not provide an automatic end-of-call report, you may need to implement server-side logic to generate this report. You would track the call's progress and, once the call ends, compile the necessary information into a report. 3. **Contact Support**: If the documentation is not clear or if you believe there should be an end-of-call report that you're not receiving, consider reaching out to the VAPI support team for clarification. 4. **Custom Event**: If the VAPI allows for custom events, you might be able to emit a custom event from the server-side when the call ends, which could act as your end-of-call report. Without an automatic end-of-call report, you may need to manually compile the call transcript and other relevant data. If the VAPI provides access to call logs or transcripts, you could retrieve this information using the call ID or session information after the call has ended. If you provide more context or details about the VAPI you are using, I may be able to offer more specific guidance.
n
@Vapi how do I get the call ID from the vapi client?
v
@nearLucid To retrieve the call ID from the VAPI client, you would typically access a property or method provided by the client that contains this information. However, the exact method to obtain the call ID can vary depending on the specific VAPI client you are using. Here's a general approach you might follow: 1. **Check the Documentation**: Look for information in the VAPI client documentation that describes how to access call details, including the call ID. 2. **Inspect the Call Object**: If the VAPI client provides a call object, it may have a property that stores the call ID. For example, you might access it like this:
Copy code
javascript
let callId = vapi.call.id; // This is just an example and may not reflect the actual API.
3. **Event Data**: The call ID might be included in the data provided by certain events emitted by the VAPI client. For example, when a call starts, an event might be emitted that includes the call ID:
Copy code
javascript
vapi.on('callStarted', (eventData) => {
    let callId = eventData.callId; // The property name may vary.
});
4. **API Methods**: Some VAPI clients have methods that return call details, including the call ID, when invoked. If you are unable to find how to access the call ID in the documentation or by inspecting the VAPI client, it's possible that the client does not expose this information directly. In such cases, you might need to manage the call ID on the server-side, where the call is initiated, and then pass it to the client through your application's logic. If you can provide more details about the VAPI client or the environment in which you are working, I can give you a more specific answer. If the information is not available, you may need to reach out to the VAPI support team for assistance.
2 Views