> For the complete documentation index, see [llms.txt](https://docs.amitysolutions.com/ekoai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.amitysolutions.com/ekoai/getting-started/eko/bot-integrations/event.md).

# Event

webhook event

There are some actions that will trigger the event to the webhook.

Currently we only have 2 actions, `Message Event` that will trigger when someone send a message and 2nd is `Join Event` that will trigger when user initiate a direct chat with the bot.

once the event message is sent to the setting webhook, developer can reply the message via [message api](https://docs.amitysolutions.com/ekoai/api-reference/botv2/botv2-api/reply-message)

## Message Event

Webhook event object which contains the sent message. The `message` property contains a message object which corresponds with the message type. You can reply to message events.

| Property   | Type     | Description                        |
| ---------- | -------- | ---------------------------------- |
| type       | String   | message                            |
| replyToken | String   | Token for replying to the event    |
| message    | Object   | message's info (information below) |
| source     | Object   | event's source info                |
| timestamp  | Datetime | timestamp of the event             |

## Join event

Event object for when user initiate chat to the bot. You can reply to join events.

| Property   | Type     | Description                      |
| ---------- | -------- | -------------------------------- |
| type       | String   | join                             |
| replyToken | String   | Token for replying to this event |
| source     | Object   | event's source info              |
| timestamp  | Datetime | timestamp of the event           |

## Message Object

| Property | Type   | Description                      |
| -------- | ------ | -------------------------------- |
| id       | String | message                          |
| type     | String | can be 'text', 'file', 'sticker' |
| groupId  | String | gid                              |
| topicId  | String | tid                              |
| text     | String | content of the message           |

## Source Object

| Property | Type   | Description                      |
| -------- | ------ | -------------------------------- |
| type     | String | can be 'text', 'file', 'sticker' |
| uid      | String | User ID                          |
| gid      | String | Group ID (Add. Version 14.1.0)   |

{% tabs %}
{% tab title="Message" %}

```javascript
{
  "events": [
    {
      "replyToken": "3ceb5b7764d3a6f08607ae834f7a1f53ce7b8eee",
      "type": "message",
      "source": {
        "type": "user",
        "userId": "62deba7109109d41e2c36696",
        "username": "demo@ekoapp.com"
      },
      "message": {
        "id": "65e1d708a70bd91d779451f3",
        "type": "text",
        "groupId": "65b918d365f74a275e29fe6e",
        "topicId": "65b918d365f74a275e29fe70",
        "text": "hi",
        "fileName": "Screenshot 2568-10-10 at 15.00.45-1760088727777.png",
        "pictureId": "4256bafe93ec4dc1bdadf9a49040a427"
      },
      "timestamp": "2024-03-01T13:24:28.489Z",
      "sessionId": "65b918d365f74a275e29fe6e_65b918d365f74a275e29fe70"
    }
  ]
}
```

{% endtab %}

{% tab title="Join" %}

```python
{
  "events": [
    {
      "replyToken": "3ceb5b7764d3a6f08607ae834f7a1f53ce7b8eee",
      "type": "join",
      "source": {
        "type": "direct_chat",
        "uid": "62deba7109109d41e2c36696",
        "gid": "65b918d365f74a275e29fe6e"
      },
      "timestamp": "2024-03-01T13:24:28.489Z"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Image Retrieval API

<mark style="color:blue;">`GET`</mark> {domain}/file/image/:pictureID?size=large

**Description**

This endpoint retrieves an **image file** that was sent by a user. The image is identified by its unique `pictureID`.

**Header**

| Key           | Value          | Descriptiom  |
| ------------- | -------------- | ------------ |
| Authorization | Bearer {token} | Access token |

**Path Parameters**

| **Parameter** | **Type** | **Description**                                     |
| ------------- | -------- | --------------------------------------------------- |
| `pictureID`   | String   | The unique identifier of the image to be retrieved. |

**Query Parameters**

| **Parameter** | **Type** | **Required** | **Description**                                                                                                          |
| ------------- | -------- | ------------ | ------------------------------------------------------------------------------------------------------------------------ |
| `size`        | String   | Optional     | Specifies the size of the returned image. Supported values include: `small`, `medium`, and `large`. Default is `medium`. |


---

# 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.amitysolutions.com/ekoai/getting-started/eko/bot-integrations/event.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.
