How to add multiple Structured Data in POST reques...
# support
w
I want to make analysis plan for my calls that will gather some informations I need from the call, like outcome described in 2 words and etc. What I have to type in my code for it to work?
v
Hi there! 👋 I wasn't able to provide the exact code you need to type for your specific environment, but I can definitely help with how to add multiple structured data in a POST request and create an analysis plan for calls to gather information like outcomes in two words. Here's how you can implement this: ## Adding Multiple Structured Data in a POST Request To add multiple structured data elements in a POST request, you'll need to define a JSON schema that specifies the structure of the data you want to extract. According to the [Vapi documentation](https://docs.vapi.ai/assistants/call-analysis), you can set up an analysis plan with structured data like this:
Copy code
json
{
  "analysisPlan": {
    "structuredDataPlan": {
      "schema": {
        "type": "object",
        "properties": {
          "call_outcome": { "type": "string" },
          "customer_name": { "type": "string" }
        },
        "required": ["call_outcome", "customer_name"]
      }
    }
  }
}
## Creating an Analysis Plan for Calls The analysis plan is configured within the
assistant.analysisPlan
as mentioned in the [Vapi API documentation](https://docs.vapi.ai/api-reference/calls/create). Here's a more complete example:
Copy code
json
{
  "analysisPlan": {
    "summaryPlan": {
      "messages": [
        {
          "key": "value"
        }
      ],
      "enabled": true,
      "timeoutSeconds": 1.1
    },
    "structuredDataPlan": {
      "messages": [
        {
          "key": "value"
        }
      ],
      "enabled": true,
      "schema": {
        "type": "object",
        "properties": {
          "call_outcome": { "type": "string", "description": "Outcome of the call described in two words" },
          "customer_name": { "type": "string" },
          "customer_email": { "type": "string" }
        },
        "required": ["call_outcome"]
      },
      "timeoutSeconds": 1.1
    }
  }
}
## Customizing the Structured Data Prompt
To specifically extract a call outcome in two words, you can customize the structured data prompt. According to the [Vapi documentation](https://docs.vapi.ai/assistants/call-analysis), you can set a custom prompt like this:
Copy code
json
{
  "structuredDataPrompt": "Extract the following information from the call: 1) The outcome of the call described in exactly two words, 2) The customer's name, 3) The customer's email address."
}
This prompt will instruct the AI to extract the specific information you need in the format defined by your schema. After the call ends, you can access the structured data through the
analysis
object:
Copy code
javascript
// When the call ends, you'll receive a call object that includes the analysis
const call = await vapiClient.calls.get(callId);
if (call.status === 'ended') {
  // Access the structured data from the analysis object
  const structuredData = call.analysis?.structuredData;
  console.log('Call Outcome:', structuredData.call_outcome);
}
Is there anything specific about this implementation you'd like me to explain further? 🙂 Sources: - [Vapi documentation](https://docs.vapi.ai/assistants/call-analysis) - [Vapi API documentation](https://docs.vapi.ai/api-reference/calls/create)
w
is there an API for getting structured data from call?
@Vapi Support Bot is there an API for getting structured data from call?
v
Hi there! 👋 Yes, there is an API for getting structured data from a call! I can help you with that. According to the information I found, you can use the
GET Get Call
API endpoint to retrieve structured data from a call. The structured data is accessible through the
analysis
object after a call ends. Here's a code example of how you can access the structured data:
Copy code
javascript
// When the call ends, you'll receive a call object that includes the analysis
const call = await vapiClient.calls.get(callId);
if (call.status === 'ended') {
  // Access the structured data from the analysis object
  const structuredData = call.analysis?.structuredData;
  console.log('Call Outcome:', structuredData.call_outcome);
}
As shown in the example, you would use the
vapiClient.calls.get(callId)
method to retrieve the call object, which contains the analysis with the structured data you defined in your analysis plan. The structured data is generated based on your
structuredDataPlan
configuration and is stored in
call.analysis.structuredData
as mentioned in the [Vapi documentation](https://docs.vapi.ai/assistants/call-analysis). Is there anything specific about accessing the structured data that you'd like to know more about? Source: - [Vapi documentation](https://docs.vapi.ai/assistants/call-analysis)
k
Thank you for reaching out to us. We've received your message and will get back to you as soon as possible.
Hi, checking if this is resolved/solved for you?
w
Yes
k
Marking this ticket as Solved ✅
6 Views