# Cài đặt Chatbot gửi tin SMS thông qua API

Giả sử ta có kịch bản: Khách hàng đăng ký thông tin trong chatbot → chatbot gửi mã coupon đến số điện thoại bằng chính sim đang lắp trên điện thoại có cài ứng dụng SMS Gateway.

### Bước 1: Tạo link API mẫu gửi tin SMS

* Truy cập mục API - Smax.Bot → đến phần Tạo link mẫu

![](/files/-MjmKN3EhA4qh__5btgJ)

* Nếu bạn muốn hệ thống tự chọn ngẫu nhiên thiết bị và sim để gửi sms thì có thể copy link nhanh có sẵn.
* Nếu bạn cần chọn riêng thiết bị / sim sẽ gửi tin thì nhập các dữ liệu mẫu và bấm nút Tạo Link mẫu. Lúc này chú ý đoạn cuối cùng của link có tham số: **\&devices=XX**
* Như vậy link API mẫu của bạn sẽ có dạng: **<https://sms.quanchatbot.com/services/send.php?key=AAAA\\&number=BBBB\\&message=CCCC\\&devices=XX>**
  * **AAAA:** API Key
  * **BBBB:** Số điện thoại người nhận SMS
  * **CCCC:** Nội dung SMS sẽ gửi
  * **XX:** Mã thiết bị / sim sẽ được chọn để gửi SMS

### Bước 2: Xây dựng kịch bản chatbot xin điện thoại và gửi coupon qua SMS

{% content-ref url="/pages/-MjNVLfcmPL83am-SD6v" %}
[Phụ lục: Hướng dẫn tạo chatbot cơ bản](/ket-noi-sms-va-chatbot/phu-luc-huong-dan-tao-chatbot-co-ban.md)
{% endcontent-ref %}

* Tạo 1 block có sử dụng User Input để xin số điện thoại khách hàng lưu vào **{{phone}}**
* Thêm thẻ Set Attributes để tạo attribute **{{sms}}** là nội dung SMS sẽ gửi.
* Dùng JSON API đã chuẩn bị ở bước 1 để gửi SMS với:
  * BBBB sẽ là attribute **{{phone}}**
  * CCCC sẽ là attribute **{{sms}}**


---

# 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://hdsms.quanchatbot.com/ket-noi-sms-va-chatbot/cai-dat-chatbot-gui-tin-sms-thong-qua-thiet-bi.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.
