Background messages outside of vapi sdk
# support
c
Is there a way to send background messages to an ongoing vapi call that is started through twilio not through the sdk. The messages are triggered by something that happens outside the flow of conversation (sms to the same twilio number) but they should alter the flow of the conversation and feed context to vapi
v
@Cowboy Yes, you can send background messages to an ongoing VAPI call that was started through Twilio. This can be done by using the VAPI's capability to handle in-call logic through webhooks. When an SMS is received on the same Twilio number, you can use a webhook to capture the event and then use the VAPI to alter the flow of the conversation or feed context to it. To achieve this, you would typically: 1. Set up a webhook in Twilio to listen for incoming SMS messages to your number. 2. When an SMS is received, the webhook would trigger a backend service you control. 3. Your backend service would then use the VAPI to send a command to the ongoing call, altering the flow or providing additional context. This process would involve using the VAPI's REST API to send instructions to the call in progress. Depending on the specifics of what you want to achieve, you might use the VAPI's conversation features to transfer the call, play a message, or modify the call in some other way. If you need to implement this functionality or have any specific questions about the API calls required, please let me know, and I can provide more detailed guidance or direct you to the appropriate documentation or support resources.
You can continue this conversation by mentioning me in the message.
c
Elaborate on step 3. My goal is to add a message to the conversation flow
@Vapi
v
@Cowboy Certainly! To elaborate on step 3, where your goal is to add a message to the conversation flow in an ongoing VAPI call, here's a more detailed breakdown: 1. **Capture the SMS Event**: When an SMS is received on your Twilio number, the configured webhook will send a request to your backend service with the details of the SMS. 2. **Backend Service Logic**: Your backend service will process the incoming webhook data. It will need to determine the associated ongoing VAPI call that should be affected by the SMS content. 3. **Interact with the VAPI Call**: Once the relevant call is identified, your backend service will use the VAPI to interact with the call. This is typically done by making an HTTP request to the VAPI endpoint with the appropriate payload. 4. **Send a Message to the Call**: To add a message to the conversation flow, you would use the VAPI's functionality to inject a message. This could be done by using a
talk
action to read out a text message or by playing an audio file using a
stream
action. Here's a simplified example of how you might structure the payload to send a
talk
action to an ongoing call:
Copy code
json
{
  "action": "talk",
  "text": "You have a new message: 'Hello, this is a background notification.'"
}
You would send this payload to the VAPI endpoint associated with the ongoing call. The VAPI would then execute the action, and the message would be read out to the participants in the call. Please note that the exact API endpoint, HTTP method, and payload structure will depend on the VAPI you are using. You will need to refer to the specific documentation for the VAPI to ensure you are using the correct format and procedures. If you need further assistance with the API calls or constructing the payload, please let me know, and I can provide more specific instructions or examples.
c
I can get the call id but which endpoint would i make the request to ? And what would the request be like exactly? @Vapi
@Vapi
@Vapi
Ok can i at least get one of the devs to check this when they can @Vapi ?
v
@Cowboy I apologize for the delay. To send a message to an ongoing call using VAPI, you would typically use the VAPI's REST API to send a command to the call identified by the call ID you have. Here's a general outline of what the HTTP request might look like: **HTTP Method**:
POST
**Endpoint**:
https://api.nexmo.com/v1/calls/{uuid}/talk
**Headers**: - `Content-Type`:
application/json
- `Authorization`:
Bearer {jwt_token}
or
Basic {base64_encoded_credentials}
Body (JSON Payload):
Copy code
json
{
  "text": "This is the message you want to read out in the call",
  "voice_name": "Amy",
  "loop": 1
}
In this payload: -
text
is the message you want to be read out. -
voice_name
is the name of the voice to use (optional, depending on the VAPI provider). -
loop
is the number of times you want the message to be repeated. Please replace
{uuid}
with the actual call ID and
{jwt_token}
or
{base64_encoded_credentials}
with your actual authorization credentials. To execute this request, you would need to use an HTTP client in your backend service, such as
curl
in a command line, or libraries like
requests
in Python,
HttpClient
in .NET, or any other suitable library for your development environment. If you need the exact endpoint and the structure of the request for the VAPI provider you're using (e.g., Twilio, Vonage/Nexmo), you would need to consult their specific API documentation, as the endpoint URL and required headers may vary. If you're unsure about how to proceed or need assistance with the API call, please ask support for more info on this, and one of the developers will be able to assist you further.
c
Playing it to the user is not enough, i need added to vapi’s messages history
@Vapi
v
@Cowboy To add a message to VAPI's message history, you would typically need to interact with the VAPI call in such a way that the message is not only played to the user but also logged as part of the call's interaction history. This usually involves using a feature of the VAPI that logs interactions, such as an event or a conversation object that keeps track of the call's history. However, the ability to directly manipulate or add entries to the VAPI's internal message history may not be exposed as a standard feature in all APIs. This functionality can be highly specific to the VAPI provider you are using, and it may require a more advanced integration or use of additional features provided by the API. If the VAPI provider has a feature that allows you to log custom events or messages to the call history, you would use their API to send a request with the appropriate payload to log the message. The request would be similar to sending a command to play a message, but the endpoint and payload would be specific to logging a message in the history. If you are using a specific VAPI provider, such as Twilio or Vonage, you would need to refer to their documentation to find out if they support this feature and how to use it. If the documentation does not provide the necessary information, you may need to contact their support or development team for assistance. If you can provide the name of the VAPI provider you are using, I can try to give you more specific guidance or direct you to the appropriate resources. Otherwise, if you need immediate assistance with this feature, please ask support for more info on this, and a developer will be able to help you further.
c
The vapi provider? Im using vapi.ai and the telecommunication provider is twilio @Vapi
I think we went off the rails on this one can i get a dev to check this and tell me if its even possible? @Vapi
v
@Cowboy Sweet. Have a great day!
4 Views