end-of-call-report structured data format not bein...
# support
s
Currently seeing an issue where the structured data that I receive from the
end-of-call-report
webhook event is not matching the json schema given as per the structured data schema in analysis plan
Copy code
export interface AnalysisPlan {
    /** This is the plan for generating the summary of the call. This outputs to `call.analysis.summary`. */
    summaryPlan?: Vapi.SummaryPlan;
    /** This is the plan for generating the structured data from the call. This outputs to `call.analysis.structuredData`. */
    structuredDataPlan?: Vapi.StructuredDataPlan;
    /** This is the plan for generating the success evaluation of the call. This outputs to `call.analysis.successEvaluation`. */
    successEvaluationPlan?: Vapi.SuccessEvaluationPlan;
}
I'm following the types for
CreateAssistantDto
closely but the returned format for structured data differs wildly from the requested format. Example call id where the llm is not abiding by the schema:
630428b7-6065-4611-8e8b-435b0da19ca5
l
I had this issue myself and I just go off the webhook response, had inconsistent results with both the DTO's and api docs - neither seem to be the final source of truth
s
The
structuredData
objects I receive are all over the place. There's no way to accommodate all the possible random shapes
r
hey guys, just FYI i had this issue and in my case because the data from end-call-report will differ based on the type of call. For example, web calls and phone calls would have different format.
s
Breaking changes like this are 🚩
l
I certainly agree... I just pick off a few fields from the end-of-call-report like
totalCost
,
duration
, etc. The rest should be available through API if you absolutely need it, although it would be asynchronous of course. I just keep an eye on the changelog https://docs.vapi.ai/changelog periodically but I shouldnt have to! VAPI is growing quite quickly so I believe they will stabilize soon and hopefully remember that this is voice ai for developers - and developers develop through documentation
s
@LBThree @Sooz could you guys also share the call ID so I could take a look?
s
@sooz can you share the working call ID so I can compare the differences and identify the issue?
s
It's in the post but here it is again 630428b7-6065-4611-8e8b-435b0da19ca5
s
The current plan's problem is that it references "the provided schema" without actually including the schema in the message to the LLM. Here's how we could approach a new analysis plan: - Create a modified structuredDataPlan that explicitly includes the schema definition in the system message - Make sure all required fields are clearly specified Here's an example format to guide the LLM's output
Copy code
ts
const assistant: CreateAssistantDTO = {
  name: "Your Assistant Name",
  model: {
    // Your model configuration
  },
  voice: {
    // Your voice configuration
  },
  firstMessage: "Hello! How can I help you today?",
  // Other assistant properties...
  
  analysisPlan: {
    structuredDataPlan: {
      enabled: true,
      schema: {
        type: "object",
        required: [
          "callerName",
          "callerEmail",
          "reasonForCall",
          "additionalNotes"
        ],
        properties: {
          callerName: {
            type: "string",
            default: "",
            description: "Name of the caller. Empty string if not provided."
          },
          callerEmail: {
            type: "string",
            default: "",
            description: "Caller's email address. Empty string if not provided."
          },
          reasonForCall: {
            type: "string",
            default: "Not provided",
            description: "A brief description of why the caller contacted us."
          },
          additionalNotes: {
            type: "array",
            items: {type: "string"},
            default: [],
            description: "Any additional relevant details. Provide each note as a separate string."
          }
        }
      },
      // NOTE: You can customize the timeout for the structured data generation
      timeoutSeconds: 30
      
      // NOTE: Other available options:
      // 
      // messages: [...] - Custom messages to send to the LLM (default shown below)
      // useAssistantLlm: boolean - Whether to use the assistant's LLM instead of default Anthropic model
      // customLlmUrl: string - URL to a custom LLM endpoint for structured data generation
    }
  }
};
Note about default messages: When messages is not explicitly provided, Vapi will use the following default messages:
Copy code
ts
[
  {
    role: "system",
    content: "You are an expert data extractor. You will be given a transcript of a call. Extract structured data per the JSON Schema. DO NOT return anything except the structured data.\n\nJson Schema:\n{{schema}}\n\nOnly respond with the JSON."
  },
  {
    role: "user",
    content: "Here is the transcript:\n\n{{transcript}}\n\n"
  }
]