Subject: Retrieving Call ID and Complete Transcrip...
# support
a
Hello everyone, I'm having trouble with VAPI integration, specifically with retrieving the Call ID (callId) and the complete transcript after the call ends (not in real-time). My goal is to sync this data with my backend to store call history (ID and transcript) and display it on the frontend once the call ends. I’ve tried several events: call-start to get the Call ID but without success. I used call-end to detect when the call ends, but I can’t link the Call ID with the complete transcript. I also tried message for transcripts, but it only works in real-time. I’ve experimented with different naming conventions like kebab case (call-start, transcript-end), camel case (callStart, transcriptEnd), and snake case (call_start, transcript_end), but none of them worked. Questions: Which event can be used to get the Call ID after the call ends? How can I retrieve the complete transcript once the call is over? Is there an event like transcript-end? How can I link the Call ID with the transcript in the backend? Should I store the Call ID from call-start and wait for call-end to get the complete transcript? I’m using TypeScript with @vapi-ai/web and the following event model: ts Copier Modifier type VapiEventNames = | 'call-end' | 'call-start' | 'message' | 'error'; I only need the complete transcript after the call ends, not in real-time. Thanks in advance for your help and any advice you can share! I appreciate any suggestions or examples. Best regards,
y
Setup the server event 'end-of-call-report' and then put in your backend url to recieve the data. this will include json which has a call object which has a child property of id. You will also get full transcript etc in this report as well
v
You can implement the end-of-call report server event solution, which is a more reliable way to get both the Call ID and complete transcript. The end-of-call report is sent as a server message when the call ends, containing all call artifacts including the transcript. Here's how to implement it: 1\. First, enable server messages in your assistant configuration by adding the following event type:
Copy code
serverMessages: ['end-of-call-report']
2\. Here's how to implement the server endpoint to handle the end-of-call report:
Copy code
import express from 'express';
import type { EndOfCallReportMessage } from '@vapi-ai/web';
const app = express();
app.use(express.json());
app.post('/vapi-webhook', async (req, res) => {
  const message = req.body as EndOfCallReportMessage;
  if (message.type === 'end-of-call-report') {
    // Store call data in your database
    await storeCallData({
      callId: message.call?.id,
      transcript: message.artifact?.transcript,
      startedAt: message.startedAt,
      endedAt: message.endedAt,
      durationSeconds: message.durationSeconds,
      // Additional data available in the report
      recordingUrl: message.artifact?.recordingUrl,
      stereoRecordingUrl: message.artifact?.stereoRecordingUrl
    });
  }
  res.status(200).json({ success: true });
});
3\. Configure your assistant to send server messages to your webhook: This solution is better than using client-side events because: 1\. The end-of-call report is sent after all processing is complete, ensuring you get the final transcript 2\. It's more reliable since it's server-to-server communication 3\. It includes additional metadata like duration, timestamps, and recording URLs 4\. It works even if the client disconnects before the call ends Let me know if you need any clarification on implementing the webhook handler or configuring the assistant!
6 Views