Send tool to vapi format
# support
e
trying to see the json struture to send to vapi from n8n
v
To send data to Vapi from n8n, you can use the following basic JSON structure:
Copy code
json
{
    "provider": "custom-knowledge-base",
    "server": {
        "url": "your-server-url"
    }
}
### Key Points: - The
provider
field is mandatory and should be set to
"custom-knowledge-base"
. - The
server
object must include a valid
url
. ### Example POST Request: When making a POST request to Vapi, you would also need to include headers for authentication:
Copy code
python
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": f"Bearer {your_auth_token}"
}

response = InternalRequestHandler.post("https://api.vapi.ai/call", json=payload, headers=headers)
Make sure to replace
your_auth_token
with your actual token for secure authentication. If you need more specific examples or have any other questions, feel free to ask! 😊 Sources: - [Report on Sending Data to Vapi from n8n](https://discord.com/channels/1211482211119796234/1211483291191083018/1340615317772308520) - [Example POST Request to Vapi](https://discord.com/channels/1211482211119796234/1211483291191083018/1343574701909344297)
e
@Vapi Support Bot im not asking about knowledge base i need the steps for tranferring a call tool what url does that transfer go to is it a http repsonse webhook response ?
v
To transfer a call using Vapi, you will primarily be working with webhooks rather than traditional HTTP responses. Here’s a step-by-step guide on how to set up the transfer call tool: ### Steps to Transfer a Call 1. **Define the
transferCall
Tool**: Create a transfer call tool that specifies the destination. Here’s an example of how to define this tool:
Copy code
javascript
   export const TRANSFER_CALL = (number: string): CreateTransferCallToolDto => {
     return {
       type: "transferCall",
       destinations: [
         {
           type: "number",
           number: number,
         },
       ],
       messages: [
         {
           type: "request-start",
           content: "Transferring your call...",
           conditions: [
             {
               param: "destination",
               operator: "eq",
               value: number
             },
           ],
         },
       ],
     };
   };
2. **Integrate with Custom LLM**: Integrate this tool within your custom Language Learning Model (LLM) configuration:
Copy code
javascript
   export const MODEL: CustomLlmModel = {
     provider: "custom-llm",
     url: `${ENDPOINT}/api/agent`,
     model: "gpt-4o",
     tools: [TRANSFER_CALL("+17753609450")]
   };
3. **Handle Streaming Responses**: Ensure that your custom LLM sends responses in Server-Sent Events (SSE) format to Vapi. 4. **Trigger the
transferCall
Function**: When a trigger condition is met, invoke the
transferCall
function:
Copy code
json
   {
     "type": "transfer",
     "destination": {
       "type": "number",
       "number": "+1234567890" // Example number
     }
   }
5. **Respond to Transfer Requests**: Your server should respond with either the destination to transfer the call or an error message:
Copy code
json
   {
     "destination": {
       "type": "number",
       "message": "Connecting you to our support line.",
       "number": "+14155552671"
     }
   }
### Webhook Response
The transfer call process is handled through webhooks. When a transfer is initiated, a
transfer-destination-request
webhook is sent to your server, which you need to set up to handle incoming requests and respond appropriately. For more detailed information, you can refer to the [dynamic call transfers guide](https://docs.vapi.ai/phone-calling/dynamic-call-transfers). If you have any more questions or need further clarification, feel free to ask! 😊 Source: - [Steps to Transfer a Call using VAPI](https://docs.vapi.ai/phone-calling/dynamic-call-transfers)
e
@Vapi Support Bot but what about the success response?
v
When transferring a call using Vapi, the success response typically includes details about the destination to which the call is being transferred. Here’s an example of what a successful response might look like:
Copy code
json
{
  "destination": {
    "type": "number",
    "message": "Connecting you to our support line.",
    "number": "+14155552671"
  }
}
### Key Points: - The
destination
object contains the type of destination (e.g., number or SIP). - The
message
field provides feedback to the user about the transfer status. - The
number
field specifies the actual number to which the call is being transferred. If the transfer cannot be completed for any reason, you would typically receive an error response instead, which might look like this:
Copy code
json
{
  "error": "Invalid destination specified."
}
If you have any more questions or need further clarification, feel free to ask! 😊 Source: - [Steps to Transfer a Call using VAPI](https://docs.vapi.ai/phone-calling/dynamic-call-transfers)
e
@Vapi Support Bot so how do i split this up correctly ? [ { "tools": [ { "name": "CEO_Call_Transfer", "type": "transferCall", "destinations": [ { "type": "number", "number": "+14058182636", "description": "Transfer the caller to the CEO.", "transferPlan": { "mode": "warm-transfer-with-twiml", "twiml": "Hello, you have an incoming call from eric huggins.They are calling to speak with you.Connecting you now." } } ], "function": { "name": "CEO_Call_Transfer", "description": "Use this function to transfer the caller to the CEO with a warm introduction using TwiML.", "parameters": { "type": "object", "properties": { "destination": { "type": "string", "enum": [ "+14058182636" ], "description": "The destination phone number to transfer the call to." } }, "required": [ "destination" ] } }, "messages": [ { "type": "request-start", "content": "I am forwarding your call to the CEO. Please stay on the line.", "conditions": [ { "param": "destination", "operator": "eq", "value": "+14058182636" } ] } ] } ] } ]
v
To split up the JSON structure for the
CEO_Call_Transfer
tool correctly for sending to Vapi, you can break it down into the main components that Vapi expects. Here’s how you can structure it: ### 1. Define the Tool You can define the tool as follows:
Copy code
json
{
  "name": "CEO_Call_Transfer",
  "type": "transferCall",
  "destinations": [
    {
      "type": "number",
      "number": "+14058182636",
      "description": "Transfer the caller to the CEO.",
      "transferPlan": {
        "mode": "warm-transfer-with-twiml",
        "twiml": "<Say>Hello, you have an incoming call from eric huggins.</Say><Pause length=\"1\"/><Say>They are calling to speak with you.</Say><Pause length=\"1\"/><Say>Connecting you now.</Say>"
      }
    }
  ],
  "function": {
    "name": "CEO_Call_Transfer",
    "description": "Use this function to transfer the caller to the CEO with a warm introduction using TwiML.",
    "parameters": {
      "type": "object",
      "properties": {
        "destination": {
          "type": "string",
          "enum": ["+14058182636"],
          "description": "The destination phone number to transfer the call to."
        }
      },
      "required": ["destination"]
    }
  },
  "messages": [
    {
      "type": "request-start",
      "content": "I am forwarding your call to the CEO. Please stay on the line.",
      "conditions": [
        {
          "param": "destination",
          "operator": "eq",
          "value": "+14058182636"
        }
      ]
    }
  ]
}
### 2. Sending to Vapi When sending this to Vapi, ensure you wrap it in the appropriate structure for the API request. Here’s an example of how you might structure the entire request: ```json { "provider": "custom-knowledge-base", "server": { "url": "your-server-url" }, "tools": [ { "name": "CEO_Call_Transfer", "type": "transferCall", "destinations": [ { "type": "number", "number": "+14058182636",
"description": "Transfer the caller to the CEO.", "transferPlan": { "mode": "warm-transfer-with-twiml", "twiml": "Hello, you have an incoming call from eric huggins.They are calling to speak with you.Connecting you now." } } ], "function": { "name": "CEO_Call_Transfer", "description": "Use this function to transfer the caller to the CEO with a warm introduction using TwiML.", "parameters": { "type": "object", "properties": { "destination": { "type": "string", "enum": ["+14058182636"], "description": "The destination phone number to transfer the call to." } }, "required": ["destination"] } }, "messages": [ { "type": "request-start", "content": "I am forwarding your call to the CEO. Please stay on the line.", "conditions": [ { "param": "destination", "operator": "eq", "value": "+14058182636" } ] } ] } ] } ``` ### Key Points: - Ensure that the
provider
and
server
fields are correctly set for your Vapi integration. - The
destinations
array should contain the correct destination details. - The
function
and
messages
sections should be structured as shown to ensure proper functionality. If you have any more questions or need further clarification, feel free to ask! 😊 Source: - [Steps to Transfer a Call using VAPI](https://docs.vapi.ai/phone-calling/dynamic-call-transfers)
m
It may also be easier for you to make a workflow and transfer a call directly to a number
e
I'm trying to do it based on the contacts assignedTo (staff)
m
Ahh gotcha okay
s
@Eric When Vapi sends a transfer-destination-request webhook to your server, your server should respond with:
Copy code
{
  "destination": {
    "type": "number",
    "number": "+14058182636",
    "message": "Connecting you to our support line."
  }
}
Key Points: 1. The type field should be "transfer" for direct transfers or "transferCall" when defining a tool. 2. The destination object must include: type: "number" for phone numbers or "sip" for SIP URIs number: The phone number to transfer to message (optional): What to say before transferring 3. For dynamic transfers based on contacts, you'll need to set up a webhook endpoint that receives the transfer request and returns the appropriate destination based on your contact's "assignedTo" field.
Do let me know if you require further help!!
9 Views