Nikhil
03/22/2025, 7:27 AMVapi Support Bot
03/22/2025, 7:29 AMmetadata
property that has been added to Say, Edge, Gather, and Workflow Nodes to [store additional information](https://docs.vapi.ai/changelog/2025/1/29)
3. For transfers between assistants, you can use the rolling-history
feature to [preserve conversation history](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341910696182681613)
Is there anything specific about context management in Vapi Workflows that you'd like me to elaborate on?
Sources:
- [Discord Thread on Data Passing Issues](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1334666797932089405)
- [Discord Thread on Variable Replacement Issues](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1324353725564715121)
- [Vapi Changelog](https://docs.vapi.ai/changelog/2025/1/29)Vapi Support Bot
03/22/2025, 7:29 AMShubham Bajaj
03/23/2025, 3:02 PMjavascript
// Better implementation for VAPI
{
"name": "Customer-Aware Outbound Assistant",
"model": {
"provider": "openai", // Or anthropic, etc.
"model": "gpt-4-turbo",
"messages": [
{
"role": "system",
"content": "You are a voice assistant making an outbound call to a customer. You have access to previous call records below. Use this history to provide personalized service, reference past interactions naturally, and avoid asking for information the customer has already provided. Never explicitly mention that you have access to call records unless the customer asks."
},
{
"role": "user",
"content": "CUSTOMER PROFILE:\nName: John Smith\nPhone: +1-555-123-4567\nAccount ID: JS12345\n\nPREVIOUS CALL HISTORY:\n\nCall #1 (2023-10-15):\n- Customer inquired about upgrading service plan\n- Discussed premium and standard options\n- Customer was concerned about pricing\n- Action items: Send pricing comparison to customer email\n\nCall #2 (2023-11-02):\n- Follow-up about pricing comparison\n- Customer still undecided\n- Main concerns: Contract length and early termination fees\n- Customer mentioned they were going on vacation until Nov 15\n\nCURRENT CONTEXT:\n- Purpose of today's call: Follow up on service plan upgrade\n- Offer: Special 20% discount available this month only\n- Note: Approval for waiving early termination fee has been granted if needed"
},
{
"role": "assistant",
"content": "I understand this context and will make the call with this history in mind."
}
],
"temperature": 0.4
},
"firstMessageMode": "assistant-speaks-first",
"firstMessage": "Hello, this is [Company Name] calling for John. Is this a good time to talk about your service plan options?"
}
Shubham Bajaj
03/23/2025, 3:02 PMjavascript
// Dynamic implementation in a VAPI workflow
async function prepareOutboundCall(customerPhone, customerId) {
// 1. Fetch customer data and call history
const customerData = await yourDatabase.getCustomer(customerId);
const callHistory = await yourDatabase.getCallHistory(customerId);
// 2. Format the history as structured content
const formattedHistory = formatCallHistory(callHistory);
// 3. Prepare the contextual message
const contextMessage = `
CUSTOMER PROFILE:
Name: ${customerData.name}
Phone: ${customerData.phone}
Account ID: ${customerData.accountId}
PREVIOUS CALL HISTORY:
${formattedHistory}
CURRENT CONTEXT:
- Purpose of today's call: ${customerData.currentCampaign.purpose}
- Offer: ${customerData.currentCampaign.offer}
- Notes: ${customerData.currentCampaign.notes}
`;
// 4. Create or update the assistant with this context
const assistant = await vapi.assistants.create({
name: `Outbound to ${customerData.name}`,
model: {
provider: "openai",
model: "gpt-4-turbo",
messages: [
{
role: "system",
content: "You are a voice assistant making an outbound call to a customer. Use the provided call history to personalize the conversation and provide continuity of service."
},
{
role: "user",
content: contextMessage
},
{
role: "assistant",
content: "I will use this context to provide a personalized experience."
}
],
temperature: 0.4
},
firstMessageMode: "assistant-speaks-first",
firstMessage: `Hello, this is ${yourCompany.name} calling for ${customerData.name}. Is this a good time to discuss your service options?`
});
// 5. Initiate the call
return vapi.calls.create({
from: yourCompany.phone,
to: customerPhone,
assistantId: assistant.id
});
}
// Helper function to format call history
function formatCallHistory(callHistory) {
return callHistory.map((call, index) => {
const date = new Date(call.timestamp).toISOString().split('T')[0];
return `
Call #${index + 1} (${date}):
- Purpose: ${call.purpose}
- Main points: ${call.summary}
- Customer concerns: ${call.customerConcerns}
- Action items: ${call.actionItems}
- Outcome: ${call.outcome}
`;
}).join('\n');
}
Shubham Bajaj
03/23/2025, 3:02 PM