# Chat

## Chat

### Create Group Chat

<mark class="gb-c-green">`POST`</mark> `https://eko-h1.dev.ekoapp.com/bot/v1/groups`

send message from bot to user's direct chat

**Headers**

| Name           | Type   | Description        |
| -------------- | ------ | ------------------ |
| Authentication | string | token from OAuth2  |
| Content-type   | string | multipart/formdata |

**Request Body**

| Name | Type   | Description                                    |
| ---- | ------ | ---------------------------------------------- |
| uid  | array  | array of user id to be the member of the group |
| name | string | name of group chat                             |
| file | file   | picture of group chat                          |

**201**

```javascript
{
    "group": {
        "_id": "69a142cc19e945b500f301ae",
        "name": "group chat create from bot new 1",
        "type": "group_chatv2",
        "settings": {
            "isPrivate": false,
            "isMemberManaged": false,
            "isCreatorManaged": true,
            "isAdminManaged": true,
            "isAutoManagedMember": false,
            "isReadOnly": false,
            "onlyAdminCanPost": false
        },
        "userCount": 3
    }
}
```

```
// example
curl --location 'https://sea-staging-h1.ekoapp.com/bot/v1/groups' \
--header 'Authorization: Bearer <TOKEN>' \
--form 'name="group chat create from bot new 1"' \
--form 'file=@"/Users/tanawootchawapon/Desktop/Screenshot 2569-02-27 at 10.51.14.png"' \
--form 'uids[]="689d65d767fc177d804b1318"' \
--form 'uids[]="5728175c7dc091401a37fe8b"'
```

### Create a topic in a group chat

<mark class="gb-c-green">`POST`</mark> `https://eko-h1.dev.ekoapp.com/bot/v1/groups/group_id/topics`

Replace group\_id with the group id you want to create a topic.

**Headers**

| Name           | Type   | Description       |
| -------------- | ------ | ----------------- |
| Authentication | string | token from OAuth2 |
| Content-type   | string | Application/json  |

**Request Body**

| Name | Type   | Description                 |
| ---- | ------ | --------------------------- |
| name | string | name of topic to be created |

**201**

```javascript
{
    "topic": {
        "_id": "69a1462819e945ce72f35736",
        "name": "TT2",
        "gid": "69a1452919e9452fd7f34db4"
    }
}
```

```
// example
curl --location 'https://sea-staging-h1.ekoapp.com/bot/v1/groups/69a1452919e9452fd7f34db4/topics' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer <TOKEN>' \
--data-urlencode 'name=TT2'
```
