Seb
10/18/2024, 9:15 PMconst options = {
method: "POST",
headers: {
Authorization: `Bearer ${vapiToken}`,
"Content-Type": "application/json",
"x-foo": "bar",
...dynamicVariablesHeaders,
},
body: JSON.stringify({
provider: "vapi",
sipUri: `sip:${callId}@sip.vapi.ai`,
assistantId: agentId,
}),
};
try {
const response = await fetch(`${this.vapiUrl}/phone-number`, options);
if (!response.ok) {
const errorData = await response.json();
console.error(
`Failed to create sip uri for call ${callId}: ${JSON.stringify(errorData)}`,
);
throw new Error(
`vapi sip uri creation failed: ${errorData.message || "Unknown error"}`,
);
}
const data = await response.json();
const { sipUri } = data;
return sipUri;
///somewhere else in the codebase:
const voiceResponse = new VoiceResponse();
const dial = voiceResponse.dial();
console.log(`Dialing ${sipUri} for call ${callId}`);
dial.sip(sipUri);
res.set("Content-Type", "text/xml");
res.send(voiceResponse.toString());
https://cdn.discordapp.com/attachments/1296944697666703360/1296944697968689183/CleanShot_2024-10-18_at_14.13.522x.png?ex=67142160&is=6712cfe0&hm=a3ebb611b2ac839931f3cb78149d9312c58760446d2cd6bf2bcda4a27b3c373d&Vapi
10/18/2024, 9:17 PMx-foo
) with a value (bar
) to your VAPI assistant. If the assistant is not saying "Hello bar" as expected, there might be an issue with how the variable is being retrieved or used within the assistant's logic.
To help you further, I would need to see the part of the code or configuration where the assistant is supposed to use the x-foo
header value. However, here are a few things you can check:
1. Ensure that the assistant logic is designed to read the x-foo
SIP header and use its value in the response.
2. Verify that the header is being sent correctly in the SIP INVITE request.
3. Check if there are any logs or debugging information that can provide insight into why the variable is not being used.
If you have access to the assistant's configuration or code, please provide the relevant section where it handles the SIP headers. Otherwise, if you need assistance with the server-side logic that should respond with the assistant's configuration, please let me know, and I can guide you through that process.Vapi
10/18/2024, 9:17 PMVapi
10/18/2024, 9:18 PMSahil
10/22/2024, 5:02 AMSahil
10/22/2024, 5:03 AMSahil
10/22/2024, 5:03 AMSahil
10/22/2024, 5:03 AMSeb
10/22/2024, 5:07 AMSeb
10/22/2024, 5:07 AMSeb
10/22/2024, 5:07 AMSahil
10/22/2024, 5:11 AMSahil
10/22/2024, 5:11 AMSeb
10/23/2024, 1:15 AMSeb
10/23/2024, 1:17 AMShubham Bajaj
10/23/2024, 8:22 PM