> For the complete documentation index, see [llms.txt](https://tailieu.smax.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tailieu.smax.ai/bot-auto/trigger/tiktok-user-trigger/bot-api.md).

# Bot API

{% hint style="warning" %}
**Trigger** **Bot API** sẽ giúp bạn gửi kịch bản chatbot cho khách hàng thông qua API
{% endhint %}

<figure><img src="https://1875681896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsr3EiPwgSuzEXI3u1tC1%2Fuploads%2FQqhKtx5pnHLoFzMw3uf9%2Fimage.png?alt=media&amp;token=0ae18f4e-56d0-4846-950b-5ab92208647f" alt=""><figcaption></figcaption></figure>

Trong danh sách trigger chọn Bot API:

<mark style="color:purple;">**(1)**</mark> Đặt tên trigger

<mark style="color:purple;">**(2)**</mark> Chọn kênh áp dụng

<mark style="color:purple;">**(3)**</mark> Cài đặt thời gian chạy nếu muốn

<mark style="color:purple;">**(4)**</mark> Bạn có thể lựa chọn giữa API Token hoặc Biz Token

* API Token: Chỉ sử dụng được cho riêng API được tạo ra do trigger đó, không sử dụng được cho API do trigger khác tạo ra. Ưu tiên sử dụng API này để đảm bảo bảo mật
* Biz Token: Token được sử dụng cho toàn bộ API

<mark style="color:purple;">**(5)**</mark> Chọn block gửi khi gọi API và chọn <mark style="color:orange;">**Lưu**</mark> để tạo trigger

<figure><img src="https://1875681896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsr3EiPwgSuzEXI3u1tC1%2Fuploads%2Fw18PQVEtweNPEzs9NTUm%2Fimage.png?alt=media&amp;token=2f1d162f-9cf3-4dd7-92de-c6af8e24d9de" alt=""><figcaption></figcaption></figure>

Sau khi tạo xong, bạn sẽ nhận được API để call tới block trong module Bot - Auto

Phương thức: POST

<mark style="color:purple;">**(1)**</mark> - API URL

<mark style="color:purple;">**(2)**</mark> - Authorization

<mark style="color:purple;">**(3)**</mark> - Body

<figure><img src="https://1875681896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsr3EiPwgSuzEXI3u1tC1%2Fuploads%2FbzdsUtLJLiqySHzy5hfs%2Fimage.png?alt=media&amp;token=de082140-81d2-4d65-ab9d-d2c74abc6dab" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Body của API
{% endhint %}

{% code fullWidth="true" %}

```
{
    "customer":
                {
                    "pid":"<customer_pid here>",
                    "page_pid":"<page_pid here>"
                }
        },
    "attrs":
        [
            {
                "name":"tên của thuộc tính muốn tạo",
                "value":"giá trị đặt cho thuộc tính"
            }
        ]
}
```

{% endcode %}

Bạn có thể lấy giá trị pid và page\_pid trong module Khách hàng

Trường attrs là 1 mảng gồm nhiều object, mỗi object sẽ tương ứng với 1 attribute bạn đặt cho khách hàng

<figure><img src="https://1875681896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsr3EiPwgSuzEXI3u1tC1%2Fuploads%2FWsmFvoDfCDTb2aTFYfbG%2Fimage.png?alt=media&amp;token=298fbdca-ec62-4551-a588-9cecb3a6d62b" alt=""><figcaption></figcaption></figure>
