Can I add variables I get back from a function cal...
# support
a
I am calling a function to file a ticket and I get a ticket ID back which I then tell to the user. I need a way to add this variable to the end-of-call report but custom variables does not work because it relies on an LLM to find the ticket id and sometimes this does not work due to transcription errors, etc. I need a way to add the ticketID value so it is easy to access from the end-of-call-report any ideas?
v
@AiTitus :) Certainly! To ensure the ticket ID is reliably included in the end-of-call report, you could modify the call flow to include a step that captures the ticket ID as a variable immediately after the ticket is filed. Then, this variable can be explicitly added to the call metadata. When the call ends, the end-of-call-report message can be structured to include this metadata, ensuring the ticket ID is transmitted accurately. Here's a suggested approach: 1. After calling the function to file a ticket and receiving the ticket ID, store the ticket ID in a variable within the call context. 2. Update the call metadata to include this ticket ID. This might involve an API call or an internal function, depending on how your system is set up. 3. Ensure that the end-of-call-report generation logic is configured to include all relevant call metadata, including the ticket ID. By following these steps, the ticket ID will be part of the call metadata and will be included in the end-of-call-report message, making it easy to access and less prone to errors compared to relying on transcription. If you need assistance with the specific implementation details or if there's a particular function you'd like to call to achieve this, please let me know, and I'll be happy to help further!
You can continue this conversation by mentioning me in the message.
a
how would I do #2 exactly?
@Vapi
v
@AiTitus :) To accomplish step #2, you would typically interact with your system's API or database to update the call metadata with the ticket ID. This process can vary greatly depending on the specifics of your system, but here's a general outline of how you might do it: 1. **API Call**: If your system exposes an API to update call metadata, you would make an HTTP request to the appropriate endpoint, including the ticket ID in the request body. The API would then handle updating the call record. 2. **Database Update**: If your system uses a database to store call information, you would execute a database query to update the record for the current call with the new ticket ID. 3. **Internal Function**: If your system has an internal function designed to update call metadata, you would call this function, passing the ticket ID as a parameter. Here's a pseudo-code example using an API call:
Copy code
pseudo
function updateCallMetadata(callId, ticketId) {
    // Define the API endpoint
    let endpoint = "https://yourapi.com/calls/" + callId + "/metadata";

    // Define the data to be sent in the API request
    let data = {
        "ticketId": ticketId
    };

    // Make the API request to update the call metadata
    httpRequest("POST", endpoint, data, function(response) {
        // Handle the response
        if (response.status == 200) {
            console.log("Call metadata updated successfully.");
        } else {
            console.log("Failed to update call metadata.");
        }
    });
}

// Example usage
updateCallMetadata(currentCallId, receivedTicketId);
If you provide more details about your system, such as whether it uses an API, a database, or a specific internal function for such updates, I can give you a more tailored solution. If there's a function within the VAPI system that you're supposed to use for this purpose, please let me know so I can assist you with the correct function call.
a
what endpoint on vapi should i push to and what are the details/docs to send the meta data too @Vapi
v
@AiTitus :) As a support bot for VAPI, I don't have access to the actual endpoints or documentation. However, typically, such information would be provided in the developer documentation or API reference guide that comes with the service. To update call metadata in a system like VAPI, you would generally look for an API endpoint related to call management or call details. The endpoint might look something like
/calls/{callId}/metadata
or
/calls/{callId}/attributes
. Here's what you generally need to do: 1. **Locate the API Documentation**: Find the section in the VAPI documentation that describes how to update call metadata. 2. **Authentication**: Ensure you have the necessary authentication tokens or credentials to make an API request. 3. **Endpoint and Method**: Identify the correct endpoint and HTTP method (e.g., POST, PUT, PATCH) for updating call metadata. 4. **Request Body**: Determine the structure of the request body and what fields are required. For updating metadata, you'll likely need to provide the call ID and the metadata fields you want to update, such as the ticket ID. 5. **Response Handling**: Understand the expected response and status codes to handle the API response correctly. If you have access to the VAPI documentation, please refer to it for the exact details. If you're unable to find this information, you might need to contact VAPI support directly for guidance on how to proceed. If you need further assistance or have specific questions about the process, feel free to ask, and I'll do my best to help you based on the information you provide.
a
i see this but i dont want it to SAY it I want it to add it as a variable accessible at end-of-call. https://docs.vapi.ai/calls/call-features#example-injecting-a-message
@Vapi
v
@AiTitus :) I understand that you're looking to add the ticket ID as a variable that can be accessed at the end of the call, rather than injecting a message into the call itself. The documentation you're referring to seems to be for a different feature, which is about injecting messages into the call. What you need is a way to store the ticket ID in the call's metadata or context so that it can be retrieved later in the end-of-call report. Since I don't have access to the actual VAPI documentation or its API specifics, I can't provide you with the exact endpoint or method. However, VAPI should have a feature to store custom variables or session data that persists for the duration of the call. Here's a general approach you might take: 1. **Set a Custom Variable**: Look for a function or API endpoint that allows you to set custom variables or session data. This might be something like
setCallVariable
or
updateSessionData
. 2. **Store the Ticket ID**: Use this function or endpoint to store the ticket ID as soon as you receive it. You'll want to give it a unique key that you can reference later, such as
ticketID
. 3. **Retrieve at End-of-Call**: Ensure that your end-of-call report logic is set up to retrieve this custom variable by its key and include it in the report. If VAPI provides a function for this purpose, you would call it with the appropriate parameters. If you're unsure of the specific function or method to use, please reach out to VAPI support for more detailed guidance on how to implement this in your system. If there's anything else I can assist you with, please let me know!
a
@User any ideas?
@Shubham Bajaj any ideas? Thanks!
s
yes through call analysis
a
@Sahil but many times it does not do it correct if its using the transcribed content, is there a different way? Thans so much @Sahil Maybe some way to inject custom variables during the call?
s
we don't have any way to inject custom variable during the call
although you can add messages
a
I don’t want it to say it though out loud is that possible
s
Please join the OH and get your question answered https://discord.gg/Q4kmWaKq?event=1288127751869431950 @AiTitus :)
s
@AiTitus :) hope your doubts are cleared now.
a
@Shubham Bajaj was not able to get in due to timing for me. Just need to know if there is a way to inject into the conversation (or prompt for the LLM) a variable without it saying it ---> during the call, i know how to do this before the call starts.
s
no as of now.
a
thanks @Shubham Bajaj so let me know how I should best handle this...1. person call in we look up their details by their name, id etc on the call with a function/tool. 2. the function/tool sends back details but also a unique ID which I do not want exposed to the customer. 3. How can i associate that ID to the chat so that I can use it later on the END call endpoint on iour end or for future functions/tools I call? Thanks! Also @Sahil if you have ideas let me know :). Thanks guys! Keep up the great work, I appreciate all your help!
s
check out server event of type request assistant.
a
yes i currently do this on inbound call and dynamically generate the agent.
the issue is mid-call and handling values sent back by a function that i do not want exposed in the chat, a way to push function variables into the agent variables for example or custom variables, make sense?
i cant rely on LLM to parse the transcript for those variables due to inaccuracies in the transcribing etc.
something like in the reply from tool "custom_variables":[ {"name":"value",...}] would be cool to parse that return from the tool/function and then put those into custom vars for the agent, make sense @Shubham Bajaj
s
yeah you can try around prompting and it will work.
a
i dont think a response back from a function/tool can send variables back to inject into custom variables returned at the end-call-report right?
what would the response look like from the tool/function?
s
you have to instrcut the llm to use those variables and create your analysis prompt around your workaroud.
a
what would a server/tool response look like coming back from the tool?
s
@AiTitus :) you have to try things.
a
@Shubham Bajaj seems like VAPI API etc is down can you confirm?
s
yeah try after 15 minutes it will work.
6 Views