Text Calls API

This page contains details on how to trigger text calls through an API that you can continue at any time with the agent.

Triggering Calls through API

After copying the API key, it is to be used as a header in the request to trigger the text conversation. Users initially would send the request without the callId. The API will then return a response from the agent along with the callId they would use for subsequent requests.

curl --location 'https://voicehub.dataqueue.ai/api/v1/calls/text-call' \
--header 'x-dq-api-key: <api-key>' \
--header 'Content-Type: application/json' \
--data '{
  "callId": "<this-is-sent-to-continue-on-specific-conversation>",
  "agentId": "<agent-id-to-be-used>"
  "context": {<json-dict-of-context>}
  "userText": "<text-to-be-sent-to-agent>"
}'

It returns a json object containing details about the call triggered

{
    "callId": "<generated-call-id>",
    "answer": "<text-answer-from-agent>"
}

To continue the conversation, you can send the callId in the body of the same above request of the conversation you want to resume

Streaming responses

If you want to show the response to the user as soon as possible, you can use the streaming endpoint. This returns Server-Sent Events (SSE), so your app can display partial agent replies as they are generated.

This endpoint's behavior is equivalent to the non-streaming endpoint above with the only difference being the response type.

curl --location --request GET 'https://voicehub.dataqueue.ai/api/v1/calls/text-call/stream' \
--header 'x-dq-api-key: <api-key>' \
--header 'Content-Type: application/json' \
--data '{
  "callId": "<this-is-sent-to-continue-on-specific-conversation>",
  "agentId": "<agent-id-to-be-used>"
  "context": {<json-dict-of-context>}
  "userText": "<text-to-be-sent-to-agent>"
}'

The response MIME type will be text/event-stream. You will receive transcript events with the following payload:

data: {"callId":"<returned-call-id>","answer":"<partial text chunk>"}

Last updated