# Lead API Backend

{% hint style="info" %}
**Page** : Tương đương 1 domain website. ( eg: abcd.com )

**Conversation** : Một cuộc hội thoại là một thông tin Khách hàng - Client (*client\_id*), gồm có Tên, email hoặc số điện thoại.

**Message** : Một tin nhắn hoặc một sự kiện được tạo ra.
{% endhint %}

## Hướng dẫn tạo kênh thu Lead.

{% tabs %}
{% tab title="1. ĐĂNG NHẬP" %}

* Đăng nhập : [**https://botbanhang.vn/page**](https://botbanhang.vn/page)
* Chọn "**Inbox Pages**"

![Chọn "Inbox Pages"](/files/-MDfiMtssk-tFYfY3jEE)
{% endtab %}

{% tab title="2. THIẾT LẬP" %}
![Chọn biểu tượng thiết lập](/files/-MDfhb5XSvIA078qSSzv)
{% endtab %}

{% tab title="3. TẠO MỚI" %}
![Chọn biểu tượng \[+\] để tạo mới](/files/-MDfip_IHMiZPwTEx0nD)
{% endtab %}

{% tab title="4. NHẬP THÔNG TIN" %}
Điền thông tin phù hợp như hình dưới với tên miền của bạn.

![](/files/-MDfjXNRCfzvzhetLKHs)
{% endtab %}

{% tab title="5. LẤY PAGE\_ID" %}

* Chọn website bạn vừa tạo ở cột bên phải.
* Chọn tab "**Thiết lập chung**" để lấy ID Page như hình bên dưới.

![Thông tin ID PAGE](/files/-MDfjlrtbodPllAjlQEs)
{% endtab %}
{% endtabs %}

## Create or Update Conversation

<mark style="color:green;">`POST`</mark> `https://chatbox-public.botbanhang.vn/v1/app/conversation/create`

Tạo mới hoặc cập nhật cuộc hội thoại.

#### Request Body

| Name           | Type   | Description                |
| -------------- | ------ | -------------------------- |
| page\_id       | string | Page ID                    |
| client\_id     | string | Client ID                  |
| client\_phone  | string | Số điện thoại khách hàng   |
| client\_name   | string | Tên khách hàng             |
| client\_avatar | string | Url avatar của khách hàng. |
| client\_email  | string | Email của khách hàng.      |

{% tabs %}
{% tab title="200 API hợp lệ." %}

```
{
    "succes": true,
    "code": 200,
    "data": {
        "client_id": "<ID>"
    }
}
```

{% endtab %}

{% tab title="403 API không hợp lệ." %}

```
{
    "succes": false,
    "code": 403,
    "message": "<MESSAGE>"
}
```

{% endtab %}
{% endtabs %}

## Create or Update Message

<mark style="color:green;">`POST`</mark> `https://chatbox-public.botbanhang.vn/v1/app/message/create`

Tạo mới hoặc cập nhật tin nhắn. Limit : **5 Tin nhắn**

#### Request Body

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| page\_id      | string | ID của Page         |
| client\_id    | string | ID của conversation |
| message\_text | string | Nội dung tin nhắn   |

{% tabs %}
{% tab title="200 API hợp lệ" %}

```
{
    "succes": true,
    "code": 200,
    "data": "SUCCESS"
}
```

{% endtab %}

{% tab title="403 API không hợp lệ" %}

```
{
    "succes": false,
    "code": 403,
    "message": "<MESSAGE>"
}
```

{% endtab %}
{% endtabs %}


---

# 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://dev.botbanhang.vn/chatbox/website/untitled.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.
