# Text Calls API

#### 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.

```bash
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

```json
{
    "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.

```bash
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>"}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dataqueue.gitbook.io/voicehub-docs/api-reference/text-calls-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
