> For the complete documentation index, see [llms.txt](https://docs.ebbot.ai/ebbot-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ebbot.ai/ebbot-docs/developer-resources/ebbot-chat/chats-and-transcripts.md).

# Chats and Transcripts

## Fetch chats and transcripts over API in Ebbot

Follow these instructions to enable fetching chats and transcripts through Ebbot Chat API.

When making calls to the Ebbot Chat API, the full API key needs to be passed as a header named`x-api-key`:

<mark style="color:yellow;">`x-api-key: <public-key>.<secret-key>`</mark>

### Fetching chats and transcripts

Two API endpoints are available:

* **List Chats**: Retrieves a paginated list of chats.
* **Fetch Transcript**: Retrieves the full transcript for a specific chat ID.

### Step 1: Retrieve a list of chats <a href="#step-1-retrieve-a-list-of-chats" id="step-1-retrieve-a-list-of-chats"></a>

The URL in the following endpoints needs to be replaced with your actual Ebbot platform URL. This is the same URL used to reach Ebbot Chat platform. It can be one of the following URLs:&#x20;

`ebbot.eu`\
`v2.ebbot.app`\
`ca.ebbot.app`

**Endpoint**

```http
GET https://<ebbot_url>/api/chats/company_chats?page={page_number}&limit={limit}
```

* **`page`** (optional): Page number for pagination (default is `1`).
* **`limit`** (optional): Number of chat records to retrieve per request (default is `15`).

#### Example Request (curl) <a href="#example-request-curl" id="example-request-curl"></a>

```bash
curl --location 'https://ebbot.eu/api/chats/company_chats?page=1&limit=15' \
--header 'accept: application/json' \
--header 'x-api-key: <public-key>.<secret-key>'
```

{% hint style="warning" %}
Don't forget to replace `<public-key>.<secret-key>` with your actual API key.
{% endhint %}

### Step 2: Retrieve chat transcript <a href="#step-2-retrieve-chat-transcript" id="step-2-retrieve-chat-transcript"></a>

Use chat IDs from the chat list response to retrieve detailed transcripts.

#### Endpoint <a href="#endpoint" id="endpoint"></a>

```
GET https://<ebbot-url>/api/chats/company_chats/{chatid}/transcript
```

Replace `{chatid}` with the desired chat ID.

#### Example request (curl) <a href="#example-request-curl" id="example-request-curl"></a>

```bash
curl --location 'https://<ebbot-url>/api/chats/company_chats/1723454103.158.fa1419c9-2568-4ea5-9ddc-00b6c0fbd69e/transcript' \
--header 'accept: application/json' \
--header 'x-api-key: <public-key>.<secret-key>'
```

#### Example transcript response <a href="#example-transcript-response" id="example-transcript-response"></a>

```json
{
  "success": true,
  "data": [
    {
      "date": "8/12/2024",
      "time": "9:15:08 AM",
      "sender": "bot",
      "text": "Hey"
    },
    {
      "date": "8/12/2024",
      "time": "9:15:08 AM",
      "sender": "bot",
      "text": "Hi there!"
    },
    {
      "date": "8/12/2024",
      "time": "9:15:12 AM",
      "sender": "user",
      "text": "I want to talk to human agent!"
    },
    {
      "date": "8/12/2024",
      "time": "9:15:16 AM",
      "sender": "bot",
      "text": "Sure! Let me connect you..."
    },
    {
      "date": "8/12/2024",
      "time": "9:15:19 AM",
      "sender": "system",
      "text": "The chat is now handled by an agent."
    },
    {
      "date": "8/12/2024",
      "time": "9:15:22 AM",
      "sender": "agent",
      "text": "Hello there!"
    }
  ],
  "request_id": "c61b72b1-d966-4873-ae06-7740fac5c00b"
}

```

#### Rate Limit

To ensure optimal performance and availability of the Chats API, a rate limit is enforced:

**Limit**: 20 requests per minute

Exceeding this limit will cause subsequent requests to time out. Please manage your request rates accordingly to avoid disruptions in service and implement handling mechanisms to pause and retry after the rate limit resets.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.ebbot.ai/ebbot-docs/developer-resources/ebbot-chat/chats-and-transcripts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
