Custom LLM Transfer Call
# support
s
Whats the process to transfer a call if I am using a custom llm? Currently I have a transferCall function setup like this. OpenAI { name: "transferCall", description: "Use this function to transfer the call. Only use it when following instructions that explicitly ask you to use the transferCall function. DO NOT call this function unless you are instructed to do so.", parameters: { type: "object", properties: { destination: { type: "string", enum: ["+7753609450"], description: "The destination to transfer the call to.", }, }, required: ["destination"], }, }; VAPI export const TRANSFER_CALL = (number: string): CreateTransferCallToolDto => { return { type: "transferCall", destinations: [ { type: "number", number: number, } as TransferDestinationNumber, ], messages: [ { type: "request-start", content: TRANSFER_CALL_MESSAGE, conditions: [ { param: "destination", operator: "eq", value: number } as any, ], }, ], }; }; I have my custom llm calling this function, but not sure exactly how to make the call transfer initiate from the vapi side?
v
@slickVik To transfer a call using a custom LLM with VAPI, you would typically follow these steps: 1. **Integration**: Ensure your custom LLM is integrated with VAPI. This might require some development work to create an interface between your LLM and the VAPI system. 2. **Voice Command**: Set up a voice command or trigger within VAPI that your customer service reps can use to initiate a call transfer. 3. **Transfer Logic**: Implement the logic within your LLM or the VAPI system to handle the transfer. This would involve identifying the destination for the transfer, such as another department or an external number. 4. **Execution**: When the voice command is given, VAPI would execute the transfer by connecting the call to the appropriate party as determined by your custom LLM. 5. **Confirmation**: After the transfer is complete, VAPI can provide a confirmation to the customer service rep that the call has been successfully transferred. If you need specific guidance on how to integrate your custom LLM with VAPI or how to set up the transfer logic, please ask support for more info on this.
You can continue this conversation by mentioning me in the message.
Got it. Tagging @User for additional help.
s
@Shubham Bajaj
@Sahil
Hey @User, thanks for taking the time at office hours today, still having an issue with this. export const MODEL: CustomLlmModel = { provider: "custom-llm", url:
${ENDPOINT}/api/agent
, model: "gpt-4o", tools: [TRANSFER_CALL("+17753609450")] }; This is my custom llm config. I'm still a little confused on the response my custom llm needs to return
@User I have a release on Wednesday, any way I can some help on this soon?
@Shubham Bajaj any help with this would be great, thanks.
s
@slickVik Here's the steps you need to perform:- 1. Define the transferCall Tool in Vapi (done by you) 2. Include the Tool in Your Custom LLM (done by you) 3. Handle Streaming Responses The LLM must send a streaming response in SSE (Server-Sent Events) format to Vapi. 4. Trigger the transferCall Function Once the tool is configured and included in your LLM, use it like any other tool. When the LLM detects the need for a call transfer, it invokes the transferCall function, passing the destination as a parameter. 5. Test the Setup Verify that when your LLM triggers the transferCall function, the streaming response is sent correctly to Vapi.
@slickVik do let me know how it goes and where your blocked.
s
I see, so I don’t need to define a custom open ai tool? The transfer tool that I define in the model is already used?
@Shubham Bajaj
s
@slickVik do let me know how it goes.
s
Do I need to define the forwarding number anywhere?
Just wondering if that is required as I see it in the documentation. @Shubham Bajaj
s
Now forwarding number is depricated instead you need to define the tool and use it with your custom-llm.
s
Got it, let me try it out. Thank you!
s
@slickVik just let me know how it goes.
s
@Shubham Bajaj I am getting the LLM to invoke the transferCall with the destination number but still not sure what I need to return. What do I need to stream back to the VAPI?
@Sahil
s
@slickVik Try out the following code snippet and let me know how it goes.
Copy code
py
                if request_payload.function_name == "transferCall" and request_payload.destination:
                    function_call_payload = {
                        "function_call": {
                            "name": request_payload.function_name,
                            "arguments": {
                                "destination": request_payload.destination
                            },
                        }
                    }
                    yield f"data: {json.dumps(function_call_payload)}\n\n"
s
Worked for me! Thank you!
f
Can you share the full code you use for the custom LLM ? I cant make the trasferCall function to trigger
s
@Felix WIlliam Can you please create a new ticket, drop your github repo link over there and ping me please.
@slickVik if your comfortable sharing you can drop your code for sharing with the community. cc: @Felix WIlliam
f
Can you help in some ways? Thank you
s
I will look into your ticket in sometime.
@slickVik Could you please assist me by reviewing the following document to help me determine its usefulness?https://gist.github.com/bajajcodes/1dc66d7efd2250155885e03d180ac152
s
@Shubham Bajaj The transfer call block does not seem to work?
const functionCallPayload = { function_call: { name: "transferCall", arguments: { destination: payload.destination, }, }, }; logEvent("Special handling for transferCall", { functionCallPayload }); res.write(
data: ${JSON.stringify(functionCallPayload)}\n\n
);
This payload is not working for me
Can you help @Shubham Bajaj
874c9353-6728-4424-95af-99ea8c20697a
Call id ^
There is no destination field in the payload?
k
Hey slickVick, do you mind making another call because your assistant didn't made the transfer tool call? Also recently openai made the change for tool call end detection so you might have to make a change in your end?
3 Views