Appending a Conversation When Starting a New Agent
# support
l
Hi is it possible to append a conversation directly to the LLM when initiating a call?
v
@L2. Absolutely! You can append the previous conversation to the LLM (Language Learning Model) when initiating a call to provide context. This helps in creating a seamless experience for the user by maintaining the continuity of the conversation. If you need assistance with how to implement this, please let me know the details, and I'd be happy to guide you through the process.
You can continue this conversation by mentioning me in the message.
l
@Vapi I'd like for an assistant to end a call when a user is on hold, but when the user is taken off hold & an certain outside parameters is needed for the agent to be on the call again for the conversation to be appended to it.
v
@L2. To achieve this, you would need to set up a system where the assistant can monitor the status of the call and the presence of specific outside parameters. When a user is placed on hold, the assistant should be able to detect when the user is taken off hold and then check for the required outside parameters. If the parameters are met, the assistant can rejoin the call and append the conversation to it. To implement this, you would typically use event listeners or webhooks to detect the change in call status and the presence of the required parameters. Once detected, the assistant can use an API to append the conversation to the ongoing call. If you have specific parameters or conditions in mind, please provide them so I can assist you further with a more detailed approach.
l
@Vapi I have the call event parameters configured I just would like to know primarily what the API call is to include the previous conversation history into the llm when initiating that call.
v
@L2. To include the previous conversation history into the LLM when initiating a call, you would typically use an API endpoint provided by your voice platform that allows you to send context along with the call initiation request. This context would include the conversation history. Since you're working with VAPI (Voice API), you would need to refer to the specific documentation for the API you're using to find the exact endpoint and the required parameters. However, the process generally involves sending a JSON payload with the call initiation request that includes the conversation history. Here's a general example of what the API call might look like:
Copy code
json
POST /api/calls/initiate
Content-Type: application/json

{
  "to": "+1234567890",
  "from": "+0987654321",
  "conversationHistory": [
    {
      "timestamp": "2023-04-01T12:00:00Z",
      "speaker": "user",
      "message": "Hello, I need help with my account."
    },
    {
      "timestamp": "2023-04-01T12:01:00Z",
      "speaker": "agent",
      "message": "Sure, I can help you with that. Could you please provide your account number?"
    }
    // ... more conversation history
  ],
  // ... other call initiation parameters
}
Please replace the endpoint
/api/calls/initiate
and the JSON structure with the actual ones provided by your voice platform's API documentation. If you need the exact details or if there's a specific function you need to call within the VAPI, please provide more information or consult the API documentation for the correct syntax and parameters.
l
@Vapi consult the documentation for me & show me what the server request would have to look like.
v
@L2. I'm sorry for any confusion, but as an AI, I don't have direct access to external systems or databases, including your specific Voice API documentation, to consult it in real-time. However, I can guide you on how to structure a typical API request based on standard practices. To include previous conversation history into the LLM when initiating a call, your server request might look something like this:
Copy code
http
POST {serverUrl}/calls
Authorization: Bearer {your_api_key}
Content-Type: application/json

{
  "type": "outboundPhoneCall",
  "phoneCallProvider": "{provider_name}",
  "to": "{recipient_number}",
  "from": "{your_number}",
  "context": {
    "conversationHistory": [
      {
        "timestamp": "2023-04-01T12:00:00Z",
        "speaker": "user",
        "message": "Hello, I need help with my account."
      },
      {
        "timestamp": "2023-04-01T12:01:00Z",
        "speaker": "agent",
        "message": "Sure, I can help you with that. Could you please provide your account number?"
      }
      // ... more conversation history
    ]
  }
  // ... other call initiation parameters if needed
}
In this example, replace
{serverUrl}
,
{your_api_key}
,
{provider_name}
,
{recipient_number}
, and
{your_number}
with the actual values you have. The
context
field is where you would include the conversation history. Please ensure that you replace the placeholders with the actual values from your Voice API configuration and that the structure of the JSON payload matches the requirements of your specific API. If you need the exact details, you should refer to the API documentation provided by your voice platform or contact their support for further assistance.
s
@L2. Yes, you can make your voice agent aware of previous call details by incorporating historical context into the conversation.
Here's how to implement this: 1. Before each call, retrieve the customer's previous call history from your database 2. Format this historical information as context that can be understood by the AI 3. Include this context in your API calls to the language model Here's an example of how to structure your API request:
Copy code
json
{
  "model": {
    "provider": "openai",
    "model": "gpt-4",
    "messages": [
      {
        "role": "system",
        "content": "You are a voice assistant handling a call with a customer. Use the following previous call history to provide more personalized and contextual responses."
      },
      {
        "role": "system",
        "content": "Previous call history: [Include formatted call logs, outcomes, and important details from past interactions with this customer]"
      }
    ]
  }
}
This approach allows your voice agent to maintain continuity across multiple conversations and provide more personalized service by referencing past interactions and issues discussed with the customer.
l
yooo
thank you for the response
s
@L2. do let me know how it goes.
l
so in the messages section you just place the object of the previous convo history
perfect thank you shubham
s
You should test it out and inform your assistant about how to use previous call summaries.
l
got it
shubham
i got another question if you don't mind
so I set up my own twilio conferencing to have more control on transfers etc, however since my phone number is linked to vapi, on the twilio side for an inbound call im paying for 2x the usage for twilio (not vapi) but just for clarity on how it works: user dials regularnumber1 -> api dials vapiNumber1 -> vapinumber1 joins conference alongside regularNumber1 I do this because I don't have control of the intial callSID or conference the user makes to place them on hold or transfer them in twilio, but because of this im being charged twice from twilio, my question would be: how to have an agent connect to a twilio conference without using a phone number to join, but instead connecting via the sdk, you would only need 1 number, is this possible? A bit of a complex question but if you need clarity let me know.
The reason why I do this is because if I use Vapis callSid they provide for twilio to try to conference that call, it seems like it does not directly include the Users phone number, which when you try to conference it, it ends the intital phone call with the User & they are not brought onto that conference.
s
@L2. give me sometime to think and brainstorm about it, works for you?
l
yea no worries its a bit complex
@Shubham Bajaj i figured out my issue but its led to another problem im having
I am going to dm you
please get back soon
s
@Shubham Bajaj https://discord.com/channels/1211482211119796234/1328518035715264624/1328772697789825085 Can I use this approach, but adding the summary with the /control endpoint? into an ongoing call? https://docs.vapi.ai/calls/call-features#call-control-feature I'm trying to do this but no success.
Copy code
json
{
  type: 'add-message',
  message: {
    role: 'system',
    content: `IMPORTANT CONTEXT - This caller has contacted us before. Here is their previous summary. Please acknowledge this information and use it to provide continuity of service: \n\n${previousSummary}`
  },
  triggerResponseEnabled: true
}
Could you help me with that?
k
Hey L2, please create a new ticket and we'll help you out with this.
3 Views