# AntBOT API

### Tích hợp và sử dụng từ ứng dụng thứ 3[​](https://developers.antbuddy.com/bot/antbot-api#t%C3%ADch-h%E1%BB%A3p-v%C3%A0-s%E1%BB%AD-d%E1%BB%A5ng-t%E1%BB%AB-%E1%BB%A9ng-d%E1%BB%A5ng-th%E1%BB%A9-3) <a href="#tich-hop-va-su-dung-tu-ung-dung-thu-3" id="tich-hop-va-su-dung-tu-ung-dung-thu-3"></a>

#### Mục đích[​](https://developers.antbuddy.com/bot/antbot-api#m%E1%BB%A5c-%C4%91%C3%ADch) <a href="#muc-dich" id="muc-dich"></a>

* Cho phép sử dụng Alice từ ứng dụng thứ 3. Yêu cầu bắc buộc đã đăng ký và trial alice từ onboarding antbuddy.
* Cho phép chạy chiến dịch từ ứng dụng thứ 3.
* Tạo alarm cho 1 liên hệ (appointment)

#### API chi tiết[​](https://developers.antbuddy.com/bot/antbot-api#api-chi-ti%E1%BA%BFt) <a href="#api-chi-tiet" id="api-chi-tiet"></a>

**Tất cả API request tới hệ thống Alice:**[**​**](https://developers.antbuddy.com/bot/antbot-api#t%E1%BA%A5t-c%E1%BA%A3-api-request-t%E1%BB%9Bi-h%E1%BB%87-th%E1%BB%91ng-alice)

**Thông qua tên miền**[**​**](https://developers.antbuddy.com/bot/antbot-api#th%C3%B4ng-qua-t%C3%AAn-mi%E1%BB%81n)

```
https://alice.antbuddy.com/rest-api
```

Authorize header bắt buộc:

```
Authorization: Bearer {access_token}
```

#### Get AccessToken[​](https://developers.antbuddy.com/bot/antbot-api#get-accesstoken) <a href="#get-accesstoken" id="get-accesstoken"></a>

```
Endpoint: /get-token/
Method: POST
Body: {
    "username": "username",
    "password": "password"
}

Description:
Username: Tên hoặc email đã tạo bên antbuddy
Password: Mật khẩu
```

### Chiến dịch[​](https://developers.antbuddy.com/bot/antbot-api#chi%E1%BA%BFn-d%E1%BB%8Bch) <a href="#chien-dich" id="chien-dich"></a>

**Kiểm tra những chiến dịch đang có**[**​**](https://developers.antbuddy.com/bot/antbot-api#ki%C3%AA%CC%89m-tra-nh%C6%B0%CC%83ng-chi%C3%AA%CC%81n-di%CC%A3ch-%C4%91ang-co%CC%81)

```
Survey Template: /rest-api/campaigns/
Method: GET
Params: {
  "name": "NESHB"
  "phonebook": "732"
  "status" "1"
}
Description:
- name : Tìm kiếm theo tên 
- phonebook : Tìm theo danh bạ
- status : Tìm theo trạng thái của chiến dịch 
1 : Đã bắt đầu
2 : Đang đợi 
3 : Đang ngừng
4 : Đã kết thúc
5 : Đã hoàn thành
```

Cấu hình callflow cho chiến dịch

#### Survey[​](https://developers.antbuddy.com/bot/antbot-api#survey) <a href="#survey" id="survey"></a>

**Tạo mẫu khảo sát (Survey Template)**[**​**](https://developers.antbuddy.com/bot/antbot-api#ta%CC%A3o-m%E1%BA%ABu-kh%E1%BA%A3o-s%C3%A1t-survey-template)

```
Create survey: /rest-api/survey-template/
Method: POST
Body: {
"name": "Tên survey",
"tts_language":  "vi",
"description": "anything"
}
Description:
- name : Tên mẫu khảo sát
- tts_language : Ngôn ngữ của mẫu khảo sát 
vi : Tiếng việt
en : Tiếng anh 
- description : Mô tả của mẫu khảo sát
```

**Kiểm tra mẫu khảo sát có sẵn**[**​**](https://developers.antbuddy.com/bot/antbot-api#ki%C3%AA%CC%89m-tra-m%C3%A2%CC%83u-kha%CC%89o-sa%CC%81t-co%CC%81-s%C4%83%CC%83n)

```
Survey Template: /rest-api/survey-template/
Method: GET
Params: {
  "search": "template name"
  "description": "description"
  "is_onboarding" "true"
  "user": "203"
}
Description:
- search : Tìm kiếm theo tên 
- description : Tìm theo mô tả
- is_onboarding : 
- user : Tìm theo id người dùng
```

**Tạo Section template**[**​**](https://developers.antbuddy.com/bot/antbot-api#ta%CC%A3o-section-template)

```
Create section: /rest-api/section-template/
Method: POST
Body: {
    "type": 1,
    "survey": ID of survey,
    "question": String (tên section),
    "script": Text (nội dụng ivr)
}

Update section: 
Endpoint: /rest-api//section-template/{id}/
Method: PUT
Body {
      "script" : "Vui lòng đợi trong giây lát."
}
```

#### Phonebook & contact[​](https://developers.antbuddy.com/bot/antbot-api#phonebook--contact) <a href="#phonebook--contact" id="phonebook--contact"></a>

**Kiểm tra phonebook hiện có**[**​**](https://developers.antbuddy.com/bot/antbot-api#ki%C3%AA%CC%89m-tra-phonebook-hi%C3%AA%CC%A3n-co%CC%81)

```
Phonebook : /rest-api/phonebook/{id} (Tìm theo id)
Method: GET
Params: {
  "search": "name"
}
Description: 
- search : Tìm theo tên danh bạ
```

**Kiểm tra contact hiện có**[**​**](https://developers.antbuddy.com/bot/antbot-api#ki%C3%AA%CC%89m-tra-contact-hi%C3%AA%CC%A3n-co%CC%81)

```
Contact : /rest-api/contact/{id} (Tìm theo id)
Method: GET
Params: {
  "phonebook" : "732"
  "search" : "0934523423"
}
Description: 
- phonebook : Tìm theo id của phonebook
- search : Tìm theo số điện thoại hoặc tên 
```

#### Tạo Phonebook[​](https://developers.antbuddy.com/bot/antbot-api#ta%CC%A3o-phonebook) <a href="#tao-phonebook" id="tao-phonebook"></a>

```
Create phonebook : /rest-api/phonebook/
Method: POST
Body: {
    "name": "name",
    "description": "rest phonebook" (option)
}

Description:
- name : Tên danh bạ
- description : Mô tả
```

**Cập nhập Phonebook**[**​**](https://developers.antbuddy.com/bot/antbot-api#c%C3%A2%CC%A3p-nh%C3%A2%CC%A3p-phonebook)

```
Update phonebook: /rest-api/phonebook/{id}/
Method: PUT
Body: {
    "name": “changed name”,
    "description": “updated descrption" 
}
Description:
- name : Thay đổi tên
- description : Thay đổi mô tả
```

#### Tạo Contact[​](https://developers.antbuddy.com/bot/antbot-api#ta%CC%A3o-contact) <a href="#tao-contact" id="tao-contact"></a>

**- Create single contact**[**​**](https://developers.antbuddy.com/bot/antbot-api#--create-single-contact)

```
Create:  /rest-api/contact/
Method: POST
Body: {
    "phonebook": {phonebook_id} (required),
    "contact": "0934890883" (required),
    "email": "linh.huynh@htklabs.com" (optional),
    "last_name": "Huynh" (optional),
    "first_name": "Linh" (optional),
    "description": "khách hàng ABC" (optional),
    "status": 1 or 0 (1: active, 0: inactivate) (required),
    "additional_vars": "{\"params_1\":\"123456\",\"params_2\":\"123456\"}" (optional)
}
```

**Cập nhập contact dựa trên id**[**​**](https://developers.antbuddy.com/bot/antbot-api#c%C3%A2%CC%A3p-nh%C3%A2%CC%A3p-contact-d%C6%B0%CC%A3a-tr%C3%AAn-id)

```
Update: /rest-api/contact/{id}/
Method: PUT
Body: {
    "contact": "0934890884",
    "status": 1,
    "country": "VN",
    "first_name": "A",
    "last_name": "B"
}
```

**- Create multiple contact (endpoint: /rest-api/bulkcontact/)**[**​**](https://developers.antbuddy.com/bot/antbot-api#--create-multiple-contact-endpoint-rest-apibulkcontact)

```
EndPoint: /rest-api/bulkcontact/
Method: POST
Body: {
  "phonebook": 293,
  "contacts": [
    {
      "contact": "0934890883",
      "email": "linh.huynh@htklabs.com",
      "last_name": "Huynh",
      "first_name": "Linh",
      "status": 1
    },
    {
      "contact": "0934890881",
      "email": "linh.huynh@htklabs.com",
      "last_name": "Huynh",
      "first_name": "Linh",
      "status": 1
    }
  ]
}
```

#### Tạo chiến dịch thoại[​](https://developers.antbuddy.com/bot/antbot-api#ta%CC%A3o-chi%E1%BA%BFn-d%E1%BB%8Bch-tho%E1%BA%A1i) <a href="#tao-chien-dich-thoai" id="tao-chien-dich-thoai"></a>

**Kiểm tra gateway hiện có**[**​**](https://developers.antbuddy.com/bot/antbot-api#ki%C3%AA%CC%89m-tra-gateway-hi%C3%AA%CC%A3n-co%CC%81)

```
Gateway List (Endpoint: /rest-api/gateway/)
Method: GET
Response: {
  "results": [
    {
      "id": 23,
      "name": "AliceDevGateway",
      "status": 1,
      "description": "AliceDevGateway",
      "addprefix": "",
      "removeprefix": "",
      "gateways": "sofia/gateway/AliceDevGateway/",
      "subdomain": "company",
      "gateway_codecs": "",
      "gateway_timeouts": "10",
      "gateway_retries": "",
      "originate_dial_string": "",
      "secondused": null,
      "created_date": "2019-12-26T04:17:12.673711Z",
      "updated_date": "2020-01-14T03:12:27.079710Z",
      "addparameter": "",
      "count_call": 0,
      "count_in_use": null,
      "maximum_call": null,
      "is_trial": true,
      "failover": null
    }
  ]
}
```

**Tạo chiến dịch**[**​**](https://developers.antbuddy.com/bot/antbot-api#t%E1%BA%A1o-chi%E1%BA%BFn-d%E1%BB%8Bch)

```
Endpoint: /rest-api/campaigns/
Method: POST
Body Example: 
{
  "name": "rest-api-cp-2"
  "description": "rest api for campaign",
  "callerid": "lh",
  "phonebook": [
    293
  ],
  "aleg_gateway": 23,
  "object_id": 351,
  "frequency": 10,
  "startingdate": "2020-02-11T02:36:39.045000Z",
  "expirationdate": "2020-02-12T02:36:39.045000Z",
  "daily_start_time": "08:00:00",
  "daily_stop_time": "21:00:00"
}

Description:
- name: required,
- description: rest api for campaign (option),
- callerid: caller name when callout (option),
- phonebook: phone book IDs list (required),
- aleg_gateway:gateway dialout (required),
- object_id: survey template application (required),
- frequency: call per minute (required),
- startingdate: Starting date campaign (required),
- expirationdate: Stopped date campaign (required),
- daily_start_time: dialy time (required),
- daily_stop_time: dialy ending time(required)
```

**Cập nhật chiến dịch thoại**[**​**](https://developers.antbuddy.com/bot/antbot-api#c%E1%BA%ADp-nh%E1%BA%ADt-chi%E1%BA%BFn-d%E1%BB%8Bch-tho%E1%BA%A1i)

```
Endpoint: /rest-api/campaigns/{id}/
Method: PUT
Body:
{
  "name": "rest-api-cp-2",
  "description": "rest api for campaign",
  "callerid": "rest_api",
  "phonebook": [
    293
  ],
  "frequency": 3,
  "startingdate": "2020-02-11T02:36:39.045000Z",
  "expirationdate": "2020-02-12T02:36:39.045000Z",
  "daily_start_time": "09:00:00",
  "daily_stop_time": "18:00:00"
}
```

#### Thay đổi trạng thái chiến dịch thoại[​](https://developers.antbuddy.com/bot/antbot-api#thay-%C4%91%C3%B4%CC%89i-tra%CC%A3ng-tha%CC%81i-chi%E1%BA%BFn-d%E1%BB%8Bch-tho%E1%BA%A1i) <a href="#thay-doi-trang-thai-chien-dich-thoai" id="thay-doi-trang-thai-chien-dich-thoai"></a>

```
Endpoint: /rest-api/campaigns/{id}/status/
Method: POST
Body: {
  "status": 1,
}

Description:
START = 1
PAUSE = 2
ABORT = 3
END = 4
```

#### Xóa chiến dịch thoại[​](https://developers.antbuddy.com/bot/antbot-api#xo%CC%81a-chi%C3%AA%CC%81n-di%CC%A3ch-thoa%CC%A3i) <a href="#xoa-chien-dich-thoai" id="xoa-chien-dich-thoai"></a>

```
Endpoint: /rest-api/campaigns/{id}
Method: DELETE
```

### Appointment[​](https://developers.antbuddy.com/bot/antbot-api#appointment) <a href="#appointment" id="appointment"></a>

#### Survey List[​](https://developers.antbuddy.com/bot/antbot-api#survey-list) <a href="#survey-list" id="survey-list"></a>

**Kiểm tra danh sách các survey**[**​**](https://developers.antbuddy.com/bot/antbot-api#ki%C3%AA%CC%89m-tra-danh-sa%CC%81ch-ca%CC%81c-survey)

```
Endpoint: /rest-api/survey-list/
Method: GET
Params: {
  "search" : "test"
  "tts_language" : "vi"
  "description" : "Test"
  "campaign" : 1243
}

Description:
- search : Tìm theo tên 
- tts_language : Tìm theo ngôn ngữ
vi : Tiếng việt
en : Tiếng anh
- description : Tìm theo mô tả
- campaign : Tìm theo id của chiến dịch
```

#### DNC (Do Not Call)[​](https://developers.antbuddy.com/bot/antbot-api#dnc-do-not-call) <a href="#dnc-do-not-call" id="dnc-do-not-call"></a>

**Kiểm tra danh sách DNC**[**​**](https://developers.antbuddy.com/bot/antbot-api#ki%C3%AA%CC%89m-tra-danh-sa%CC%81ch-dnc)

```
Endpoint: /rest-api/dnc-list/
Method: GET
```

**Kiểm tra DNC Contact**[**​**](https://developers.antbuddy.com/bot/antbot-api#ki%C3%AA%CC%89m-tra-dnc-contact)

```
Endpoint: /rest-api/dnc-contact/
Method: GET
```

**Thêm vào DNC list**[**​**](https://developers.antbuddy.com/bot/antbot-api#th%C3%AAm-va%CC%80o-dnc-list)

```
Endpoint: /rest-api/dnc-list/
Method: POST
Body: {
  "name" : "name dnc",
  "description" : "test"
}

Description:
- name : Tên DNC
- description : Mô tả
```

**Thêm vào DNC Contact**[**​**](https://developers.antbuddy.com/bot/antbot-api#th%C3%AAm-va%CC%80o-dnc-contact)

```
Endpoint: /rest-api/dnc-contact/
Method: POST
Body: {
  "phone_number" : "0324324343",
  "dnc" : "343"
}

Description:
- phone_number : Số điện thoại
- dnc : ID của DNC list
```

#### Report[​](https://developers.antbuddy.com/bot/antbot-api#report) <a href="#report" id="report"></a>

**Kiểm tra báo cáo**[**​**](https://developers.antbuddy.com/bot/antbot-api#ki%C3%AA%CC%89m-tra-ba%CC%81o-ca%CC%81o)

```
Endpoint: /rest-api/cdr/
Method: GET
Params: {
  "callid" : "res232-fsf3-sfdsf"
  "callerid" : "admin"
  "phone_number" : 094343434
  "from_date" : 2023-04-06T10:52:56.162517Z
  "to_date" : 2023-03-28T08:05:07.495988Z
  "duration" : 34
  "billsec" : 3
  "disposition" : FAILED
  "hangup_cause" : UNALLOCATED_NUMBER
  "sip_term_status" : 404
  "sip_term_cause" : 2
  "endpoint_disposition" : ANSWER
  "campaign" : 23
  "alarm" : false
  "otp" : true
}

Description:
- callid : Id cuộc gọi
- callerid : Id người gọi
- phone_number : Số điện thoại
- from_date : Thời điểm bắt đầu
- to_date : Thời điểm kết thúc
- duration : Thời lượng cuộc gọi
- billsec : 
- disposition : 
- hangup_cause : Lí do ngừng cuộc gọi
- sip_term_status : 
- sip_term_cause :
- endpoint_disposition :
- campaign : Id của chiến dịch
- alarm : Những cuộc gọi nhắc lịch
true : Những cuộc gọi nhắc lịch
false : Những cuộc gọi không nhắc lịch
- otp : Những cuộc gọi OTP
true : Những cuộc gọi OTP
false : Những cuộc gọi không phải OTP
```

#### Subcribers[​](https://developers.antbuddy.com/bot/antbot-api#subcribers) <a href="#subcribers" id="subcribers"></a>

**Xem thành viên chiến dịch**[**​**](https://developers.antbuddy.com/bot/antbot-api#xem-tha%CC%80nh-vi%C3%AAn-chi%C3%AA%CC%81n-di%CC%A3ch)

```
Get subcribers : /rest-api/subscriber-list/
Method: GET
Params: {
  "campaign" : 2323
  "contact" : 094344334
  "status" : 2
  "duration" : 43
  "billsec" : 23
}

Description:
- campaign : Id của chiến dịch
- contact : Số điện thoại
- status : trạng thái
- duration : Thời lượng cuộc gọi
- billsec : 
```

#### Calendar[​](https://developers.antbuddy.com/bot/antbot-api#calendar) <a href="#calendar" id="calendar"></a>

**Thiết lập lịch**[**​**](https://developers.antbuddy.com/bot/antbot-api#thi%E1%BA%BFt-l%E1%BA%ADp-l%E1%BB%8Bch)

```
Endpoint: /rest-api/calendar-setting/
Method: POST
Body: {
  "label": "rest-api-cp-2",
  "callerid": "mantest_calendarsettings",
  "caller_name": "",
  "call_timeout": 60,
  "survey": 953,
  "aleg_gateway": 23
}

Description:
- label: tên  (required),
- callerid: caller hiển thị (option),
- caller_name: tên người gọi (option),
- call_timeout: thời gian cuộc gọi timeout  bằng giây (required),
- survey": id của khảo sát (required), get from Survey List API
- aleg_gateway: cổng nối gọi ra (required),
  Get from Gateway List API
```

**Calendar User**[**​**](https://developers.antbuddy.com/bot/antbot-api#calendar-user)

```
Endpoint: /rest-api/calendar-user/
Method: POST
Body:
{
  "username": "cal-rest-user-resp2",
  "password": "12345678" - required,
  "calendar_setting": 4 - required
}

Description:
- username: user login (required)
- calendar_setting: Calendar setting,
 GET from calendar-setting API
```

**Tạo lịch**[**​**](https://developers.antbuddy.com/bot/antbot-api#t%E1%BA%A1o-l%E1%BB%8Bch)

```
Endpoint: /rest-api/calendar/
Method: POST
Body: {
  "name": "linh-calendar-rest",
  "user": 5 - required
}
​
Description: 
- name: required  
- user: Calendar User List, 
Get from calendar-user API
```

**Tạo sự kiện**[**​**](https://developers.antbuddy.com/bot/antbot-api#t%E1%BA%A1o-s%E1%BB%B1-ki%E1%BB%87n)

```
Endpoint: /rest-api/event/
Method: POST
Body: {
  "title": "today-linhhv",
  "description": "",
  "start": "2020-02-15T09:30:39.177000Z",
  "end": "2020-02-15T10:13:39.177000Z",
  "creator": 115,
  "calendar": 7
}

Description:
- title: Tên sự kiện (required)
- start: Thời gian bắt đầu (required)
- end: Thời gian kết thúc (required)
- creator: calendar user được gắn vào, 
  được lấy từ calendar-user API
- calendar: Lịch gắn vô sự kiện, 
được lấy từ calendar API
```

**Tạo Alarm**[**​**](https://developers.antbuddy.com/bot/antbot-api#t%E1%BA%A1o-alarm)

```
Endpoint: /rest-api/alarm/
Method: POST
Body: 
{
  "alarm_phonenumber": "0934890883",
  "date_start_notice": "2020-02-12T02:49:33.572Z",
  "phonenumber_transfer": "",
  "event": 8
}

Description: 
- alarm_phonenumber: call to number (required),
- date_start_notice: starting date alarm - (option- default current time),
- phonenumber_transfer: phone to transfer (option),
- event: related event (required), event list get from event API, method Get
```


---

# 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://docs.antbuddy.com/huong-dan-tich-hop-api-team-technical-api-integration-guide-technical-team/antbot/antbot-api.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.
