Storing Call Data and Metadata via Vapi API Post-C...
# support
j
Is there a way to send an API request to the user's server at the end of a call? This request should include data collected during the conversation, along with metadata such as the user's name and phone number that was provided when creating the call using the Vapi Create Call API. I am planning on storing this information in database. I already have person's name and phone number through vapi voice assistant, I want to call that person and collect appointment date and time. and finally store all this data (name, phone, date and time) in my database.
v
Yes, you can receive a POST request to your server at the end of a call with all conversation data and metadata. Here’s a Node.js/Express example to handle the "end-of-call-report" and extract the info you need:
Copy code
js
app.post('/vapi-webhook', (req, res) => {
  if (req.body.message?.type === "end-of-call-report") {
    const call = req.body.message.call;
    const phone = call?.from?.phoneNumber;
    // Extract name, date, time from summary or transcript as needed
    const summary = req.body.message.summary;
    // Save { name, phone, date, time } to your DB here
  }
  res.sendStatus(200);
});
You’ll need to parse the summary/transcript to extract appointment details. This lets you store all relevant data after each call. [See Vapi docs for details](https://docs.vapi.ai/server-url/events#end-of-call-report) Source: - [Server Events End of Call Report](https://docs.vapi.ai/server-url/events#end-of-call-report)
k
Set up the server.url and hooks.on = call.ending in your assistant or Create Call config, and define a structuredDataPlan to extract appointment info. Vapi will send this structured JSON to your server, which you can then validate and store in your database..