> For the complete documentation index, see [llms.txt](https://api.omicall.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.omicall.com/omicall-api/ai-api/autocall.md).

# Gọi tự động sử dụng callBot

## Gọi tự động tới một số điện thoại khách hàng

<mark style="color:green;">`POST`</mark> `[URL]/api/call_bot/execute_by_phone`

Tạo một phiên callBot với tham số đầu vào là một kịch bản callbot và 1 danh sách các thông tin liên hệ

#### Query Parameters

| Name                                  | Type   | Description                                                                                               |
| ------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------- |
| cid<mark style="color:red;">\*</mark> | String | <p>Số hotline hay số SIP sẽ thực hiện chạy phiên.</p><p></p><p>Nếu gọi nội mạng, truyền giá trị rỗng.</p> |

#### Headers

| Name                                        | Type   | Description               |
| ------------------------------------------- | ------ | ------------------------- |
| Content-type                                | string | application/json          |
| Authorization                               | string | Access Token Bearer token |
| x-api-key<mark style="color:red;">\*</mark> | String | API key được cung cấp     |

#### Request Body

<table><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>speed</td><td>number</td><td><p>Tốc độ đọc.Từ chậm : -3. Đến nhanh : 3. </p><p>Mặc định là 0</p></td></tr><tr><td>voice</td><td>string</td><td><p>Giọng đọc, có thể một trong các giá trị sau<br>+ "northern_female_ngocanh" : Ngọc Anh</p><p>+ "southern_female_honganh" : Hồng Anh</p><p>+ "southern_male_tienhuy" : Tiến HuyQ</p></td></tr><tr><td>cid</td><td>string</td><td>Đầu số dùng để gọi tự động. <br><em>Nếu không truyền, mặc định ưu tiên gọi nội mạng</em></td></tr><tr><td>name</td><td>string</td><td>Tên của phiên gọi tự động</td></tr><tr><td>num_retry</td><td>Integer</td><td>Số lần gọi lại khi không nghe máy. Mặc định là 0</td></tr><tr><td>num_per_call</td><td>Integer</td><td>Số cuộc gọi mỗi lần. Mặc định là 15 </td></tr><tr><td>distance_per_call</td><td>Integer</td><td>Khoảng cách thời gian , giữa các lần gọi. Mặc định là 30s</td></tr><tr><td>distance_retry</td><td>Integer</td><td>Khoảng cách giữa các lần gọi lại . Mặc định là 0</td></tr><tr><td>bot_script_id</td><td>String</td><td>Id kịch bản, được lấy ở danh sách trong hệ thống</td></tr><tr><td>send_time</td><td>Number</td><td><p>Thời gian thực hiện phiên (milisecond)</p><p></p><p>Nếu không truyền giá trị, sẽ thực hiện gọi ngay</p></td></tr><tr><td>contact_info<mark style="color:red;">*</mark></td><td>Array</td><td><p>Danh sách contact cần gọi</p><p>Giá trị: </p><pre class="language-postman_json"><code class="lang-postman_json">{
            "phone":"0395187***",
            "email":"",
            "ext_contact_code":"",
            "mapping_variables":{
                "gender1":"Anh",
                "full_name":"Trần Văn Tiến",
                "address":"Phan Huy Ích",
                "mail":"tientv@***.com",
                "birthday":"11/10/19***"
            }
        }
</code></pre><p></p><ul><li>phone : Số điện thoại KH</li><li>email: Email khách hàng nếu có</li><li>ext_contact_code : Mã KH bên thứ 03</li><li>mapping_variables : Hỗ trợ cho phép truyền biến động từ đối tác. Danh sách và chi tiết biến động cần truyền trong (API lấy danh sách KB Callbot)  </li></ul></td></tr><tr><td>ext_session_id</td><td>String</td><td><p>Mã định danh phiên bên ngoài CRM (tránh trường hợp lên trùng phiên do double summit)</p><p>Nếu có giá trị field này, mới kiểm tra trùng</p></td></tr></tbody></table>

{% tabs %}
{% tab title="200 Thông tin phiên gọi tự động" %}

```
{
    "instance_id": "stg",
    "payload": {
        "bot_script_id": "653b155db0f794**********",
        "autocall_id": "6552de1891be25**********",
        "errors" : [
		    	{
		  	  	"phone" : "09xxxxxxxx",
		  	  	"error_code" : "number_dnc",
		    		"message" : "Number DNC"
		    	}
	    	]
    },
    "instance_version": "1.2.164",
    "key_enabled": false,
    "status_code": 9999
}
```

{% endtab %}
{% endtabs %}

## Lấy danh sách kịch bản bot

<mark style="color:blue;">`GET`</mark> `[URL]/api/call_bot/script/list`

Lấy danh sách kịch bản callBot do khách hàng thiết lập

{% tabs %}
{% tab title="200: OK " %}

```json
{
	"instance_id": "stg",
	"payload": [
		{
			"id": "64915bc76a690c0edad14723",
			"name": "Thông báo điểm thi",
			"variables": [
				{
					"field_name": "tên thí sinh",
					"field_code": "tên thí sinh",
					"field_value": "",
					"field_type": "",
					"type": "",
					"is_dynamic_attribute": true
				},
				{
					"field_name": "Toán",
					"field_code": "uB131frQEU",
					"field_value": "",
					"field_type": "single_text",
					"type": "CONTACT",
					"is_dynamic_attribute": true
				}
			]
		},
		{
			"id": "64a922f61900954f5419d503",
			"name": "Cảnh báo từ khóa tiêu cực",
			"variables": [
				{
					"field_name": "",
					"field_code": "nhanvien",
					"field_value": "",
					"field_type": "",
					"type": "",
					"is_dynamic_attribute": true
				},
				{
					"field_name": "",
					"field_code": "tenkhachhang",
					"field_value": "",
					"field_type": "",
					"type": "",
					"is_dynamic_attribute": true
				},
				{
					"field_name": "",
					"field_code": "sodienthoai",
					"field_value": "",
					"field_type": "",
					"type": "",
					"is_dynamic_attribute": true
				},
				{
					"field_name": "",
					"field_code": "thoigiangoi",
					"field_value": "",
					"field_type": "",
					"type": "",
					"is_dynamic_attribute": true
				},
				{
					"field_name": "",
					"field_code": "diem",
					"field_value": "",
					"field_type": "",
					"type": "",
					"is_dynamic_attribute": true
				}
			]
		}
	],
	"instance_version": "1.2.164",
	"key_enabled": false,
	"status_code": 9999
}
```

{% endtab %}
{% endtabs %}

## Đếm số lượng cuộc gọi của phiên

<mark style="color:blue;">`POST`</mark> `[URL]/api/call_bot/call/count`

Header

| Name          | Type   | Required | Description                  |
| ------------- | ------ | -------- | ---------------------------- |
| Authorization | String | Yes      | Access token: Bearer 'token' |
| Content-Type  | String | Yes      | `application/json`           |

Request Body

| Field        | Type   | Required | Description                                                        |
| ------------ | ------ | -------- | ------------------------------------------------------------------ |
| autocall\_id | String | Yes      | Id của phiên autocall                                              |
| phones       | Arrays | No       | Danh sách số điện thoại cần đếm. Nếu để trống sẽ đếm toàn bộ phiên |

Example cURL

```
curl --location '[URL]/api/call_bot/call/count' \
--header 'x-api-key: <your_api_key>' \
--header 'Content-Type: application/json' \
--data '{
    "autocall_id": "6912a712f9c97b58c60b9f63",
    "phones": [
        "070599****"
    ]
}'
```

{% tabs %}
{% tab title="200: OK" %}

```json
{
    "instance_id": "stg",
    "payload": 0,
    "instance_version": "1.2.164",
    "key_enabled": false,
    "status_code": 9999
}
```

{% endtab %}
{% endtabs %}

## Lấy chi tiết kịch bản callbot

<mark style="color:blue;">`GET`</mark> `[URL]/api/call_bot/get_by_id/:id`

Lấy chi tiết kịch bản callBot do khách hàng thiết lập

#### Query Parameters

| Name                                 | Type   | Description         |
| ------------------------------------ | ------ | ------------------- |
| id<mark style="color:red;">\*</mark> | String | Id kịch bản callbot |

#### Headers

| Name                                        | Type   | Description               |
| ------------------------------------------- | ------ | ------------------------- |
| Content-type                                | string | application/json          |
| Authorization                               | string | Access Token Bearer token |
| x-api-key<mark style="color:red;">\*</mark> | String | API key được cung cấp     |

{% tabs %}
{% tab title="200: OK" %}

```json
{
  "instance_id": "stg",
  "instance_version": "1.2.164",
  "key_enabled": false,
  "payload": {
    "id": "69e82c04d06bd25e152a5762",
    "uuid": "0739227b-677f-441f-b09a-9ee9ecc11937",
    "tenant_id": "634cb99eb255dc23e1abfe56",
    "name": "123123",
    "variables": [],
    "connections": [
      {
        "sourceHandle": "1",
        "animated": false,
        "style": {
          "strokeWidth": 3,
          "stroke": "#00B1FF"
        },
        "id": "reactflow__edge-wfyesGZDhO1-xkEm6QmM6M1",
        "source": "wfyesGZDhO",
        "type": "custom",
        "targetHandle": "1",
        "target": "xkEm6QmM6M"
      }
    ],
    "nodes": [
      {
        "id": "wfyesGZDhO",
        "node_type": "BEGIN",
        "next_nodes": [
          "xkEm6QmM6M"
        ],
        "is_collapse": false
      },
      {
        "id": "xkEm6QmM6M",
        "node_type": "STAFF",
        "template_content": "",
        "return_template_content": "",
        "wrong_response_content": "",
        "customer_response_delay": 10000,
        "is_collapse": false,
        "audio_file": {
          "name": "ghi âm.mp3",
          "src": "634cb99eb255dc23e1abfe56/callbot_recording_file/2026/04/9f921f48-8700-4209-808e-0496d45279db.mp3",
          "duration": "21.6",
          "pbx_source": "/mnt/data/freeswitch/recordings/testtruong1710/callbot/2026/04/af684879-3e4e-4f4b-995e-fdfebbc6a6ca.mp3"
        }
      }
    ],
    "is_draft": true,
    "created_date": 1776823300555,
    "last_updated_date": 1776823300894,
    "last_publish_time": 1776823300555,
    "created_by": {
      "id": "634cb99eb255dc23e1abfe59",
      "name": "TruongND",
      "contact_id": "634cb9ba5434a97a92dda131",
      "avatar_url": null,
      "ref_type": null,
      "gender": null,
      "email": null
    },
    "public_key": "cb79b64f-b6a4-4962-a5c7-e1aeea85b530",
    "last_updated_by": {
      "id": "634cb99eb255dc23e1abfe59",
      "name": "TruongND",
      "contact_id": "634cb9ba5434a97a92dda131",
      "avatar_url": null,
      "ref_type": null,
      "gender": null,
      "email": null
    },
    "is_deleted": false,
    "collect_authentication_data": "NONE",
    "system_intent_ids": [],
    "system_entity_type_ids": [],
    "version": 1,
    "is_newest_version": false,
    "is_publish": true,
    "custom_variables": [],
    "classifies": [],
    "variables_with_order": [],
    "speed": 1,
    "voice": "northern_female_ngocanh",
    "type": "NORMAL",
    "is_interrupt": false,
    "parse_datetime": false
  },
  "status_code": 9999
}
```

{% endtab %}
{% endtabs %}

## Báo cáo phân tích phiên

<mark style="color:green;">`POST`</mark> /api/call\_bot/analyzed\_log/list

Báo cáo dữ liệu đã phân tích, đánh giá giữa Chủ đề, ý định và tính tương thích&#x20;

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

Request Param

| Name | Type    | Description                      |
| ---- | ------- | -------------------------------- |
| page | integer | Trang , mặc định là 1            |
| size | integer | Kích thước trang, mặc định là 50 |

**Body**

| Name      | Type   | Description                     |
| --------- | ------ | ------------------------------- |
| keyword   | string | Từ khoá tìm kiếm                |
| ref\_uuid | string | Id phiên của chiến dịch callbot |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "instance_id": "stg",
    "payload": {
        "items": [
            {
                "_id": "67ee11592f5d1d60570ee70b",
                "tenant_id": "67eb4821758a5a4891925d99",
                "is_deleted": false,
                "created_date": 1743655257449,
                "last_updated_date": 1743655257449,
                "create_by": {
                },
                "last_update_by": {
                },
                "content": "vâng",
                "content_search": "vang",
                "content_logs": [],
                "status": "new",
                "intent": "omi_intent_confirm_right",
                "intent_id": "67ee01eaf05f0746d6d3583c",
                "entities": [],
                "entity_details": [],
                "session_id": "1400d541-0403-40dc-8ab4-12fec19c530b",
                "node_id": "peIbVXdZuH",
                "ref_uuid": "67ee1138e4c40956087cd265",
                "callbot_uuid": "e6465c1d-ab6f-472b-a0bb-e21588298882"
            }
        ],
        "page_number": 1,
        "page_size": 50,
        "total_items": 1,
        "total_pages": 1,
        "has_next": false,
        "next_page": 1,
        "has_previous": false,
        "previous_page": 1,
        "extension": null
    },
    "instance_version": "1.2.164",
    "key_enabled": false,
    "status_code": 9999
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}
