Live Context via API Payload
# support
s
Is there a way that we can include context in the workflow assistant API payload? We have an outbound call agent calling drivers for status updates and we'd like to include all shipment details in the payload via metadata or other instead of having to do a tool call. Using the current screen shot method is not working but hoping to avoid the tool call for context. Since the workflow is a static flow how would the context be injected since every shipment has different information? Call ID: 70c198d6-5578-41bb-ad61-350e7d1d60c8 (Driver doesn't have the context of the load being delivered to Salt Lake City. https://cdn.discordapp.com/attachments/1354823297296109620/1354823299460366564/Workflow_Context_Payload.png?ex=67e6b105&is=67e55f85&hm=946999f028c1be22d164b1fa21d38597abe0b9b8ef8631a1e438f3402814638b&
v
Hi there! 👋 I see you're trying to include shipment details in your workflow assistant API payload without using tool calls. While I couldn't find information about the "screenshot method" you mentioned, I can definitely help with alternative approaches to inject context into your static workflow. ## Using
assistantOverrides
with
metadata
or
variableValues
The most direct way to include shipment details is through the
assistantOverrides
object in your API payload. There are two main approaches: ### 1. Using
assistantOverrides.metadata
You can include shipment details in the
metadata
field as shown in your example:
Copy code
json
{
  "assistantOverrides": {
    "metadata": {
      "content": "BOL# 5666, driver number: 913-289-1827, destination: Salt Lake City, Utah, Appointment time: March 30th 8:00 AM"
    }
  }
}
### 2. Using
assistantOverrides.variableValues
(Recommended) This is often more structured and reliable for dynamic content. You'll need to set up template variables in your assistant's prompts first:
Copy code
json
{
  "assistantOverrides": {
    "variableValues": {
      "bol_number": "5666",
      "driver_number": "913-289-1827",
      "destination": "Salt Lake City, Utah",
      "appointment_time": "March 30th 8:00 AM"
    }
  }
}
Then in your assistant's prompts, use the variables like:
Hello driver, I'm calling about shipment {{bol_number}} headed to {{destination}}
. According to [Vapi's documentation on dynamic variables](https://docs.vapi.ai/assistants/dynamic-variables), you need to add the
{{variableName}}
in this format in all your prompts where you want to use the variable. ## Other Methods to Include Context ### Using a Knowledge Base You can create a knowledge base with shipment details and attach it to your assistant via the PATCH endpoint: ```json { "model": { "knowledgeBaseId": "", "temperature": 0.2, "provider": "openai", "model": "gpt-4o", "messages": [ {
"content": "You are a smart assistant who responds to user queries using the information supplied by outside context.", "role": "system" } ] } } ``` ### Using a Control URL When creating a room (web or phone), you can request a control URL that can be used to inject messages with shipment details during the conversation. ### Server-Side Transformation If you need more complex processing, you might need to implement a transformer function on your server to format the payload before sending it to Vapi. Is there a specific method from these that you'd like me to explain in more detail? Sources: - [Vapi Documentation on Dynamic Variables](https://docs.vapi.ai/assistants/dynamic-variables) - [Discord Thread on assistantOverrides](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1338961731367604284) - [Discord Thread on Using Metadata](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341914745661554788) - [Vapi Knowledge Base Documentation](https://docs.vapi.ai/knowledgebase)
s
@saulgoodman4072 You can include shipment details and other context in your Vapi workflow calls by using the
assistantOverrides
parameter with
variableValues
. This allows you to inject dynamic data into your static workflow without needing tool calls. ## Detailed Solution Based on the codebase, here's how you can include shipment details in your workflow: 1. **Use
assistantOverrides
with `variableValues`**: When creating a call, you can pass an
assistantOverrides
object that includes
variableValues
containing all your shipment details:
Copy code
javascript
   const response = await vapiClient.calls.create({
     phoneNumberId: "your-phone-number-id",
     customer: { number: "driver-phone-number" },
     assistantId: "your-workflow-assistant-id",
     assistantOverrides: {
       variableValues: {
         shipment: {
           id: "SH12345",
           destination: "123 Main St, Anytown, USA",
           expectedArrival: "2023-06-01T14:00:00Z",
           status: "In Transit",
           items: ["Item1", "Item2"],
           weight: "2500 lbs",
           specialInstructions: "Fragile items, handle with care"
         },
         driver: {
           name: "John Smith",
           vehicleId: "V789"
         }
       }
     }
   });
2. **Reference these variables in your workflow**: In your workflow, you can reference these variables using LiquidJS syntax:
Copy code
Hello {{ driver.name }}, I'm calling about shipment {{ shipment.id }} 
   that is heading to {{ shipment.destination }}. 
   The expected arrival time is {{ shipment.expectedArrival | date: "%b %d, %Y, %I:%M %p" }}.
3. **Access in nodes**: The workflow system automatically processes these variables and substitutes them in your workflow's text content, including in: - Node content in say/gather nodes
4 Views