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

**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"
    }
  ]
}
```

**Join**

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

## Image Retrieval API

<mark class="gb-c-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`. |
