Comment on page

Webhook

Version 1.3
CareSoft cung cấp tính năng hỗ trợ các webhook để nhận thông tin cập nhật người dùng, tổ chức, phiếu ghi, các sự kiện realtime cho cuộc gọi vào, sự kiện kết thúc cuộc gọi trên smartdialer.

I. Chuẩn bị thông tin

Khách hàng gửi thông tin server webhook cho support hỗ trợ cấu hình bao gồm:

  • Callback Url (VD: http://sample.com/api/webHook)
  • SecretKey (option)
  • Các sự kiện hỗ trợ đăng ký: Người dùng:user Tổ chức: organization Phiếu ghi: ticket.voice, ticket.voice_out, ticket.ivr, ticket.voicemail, ticket.voice_campaign, ticket.email, ticket.email_out, ticket.web, ticket.api, ticket.sms_out, ticket.ticket_form, ticket.ticket_sharing, ticket.chat, ticket.facebook, ticket.inbox_facebook, ticket.inbox_facebook_out, ticket.facebook_rating, ticket.facebook_lead_ads, ticket.instagram, ticket.chat_instagram, ticket.inbox_zalo, ticket.inbox_zalo_out, ticket.inbox_zalo_zns, ticket.zalo_lead_form SmartDialer: smart_dialer Cuộc gọi vào: call_in
LƯU Ý: Event sẽ được trả về theo method POST. Request body dạng application/json. Header bao gồm X-Hub-Signature được mã hoá body theo chuẩn HmacSHA1 với secret key đã được cấu hình (Kết quả mã hoá ở dạng uppercase)
Link test mã hoá Signature: https://tools.onecompiler.com/hmac-sha1
VD:
Request Body: {"ticket_id":1} SecretKey: CS123
Signature: 420A69CE7D3C36559E9828D6361530DF30065D37

II. Các sự kiện webhook

2.1. Sự kiện trên người dùng

Sự kiện người dùng
// Sự kiện người dùng được tạo
{
"object": "user",
"action": "create",
"user": {
"id": 0,
"username": "",
"account_id": 0,
"email": "",
"email2": "",
"phone_no": "",
"phone_no2": "",
"phone_no3": "",
"role_id": 3,
"facebook": "",
"note": "",
"gender": 0,
"organization_id": 0,
"detail": "",
"avatar": "",
"user_info1": "", //facebook name
"user_info5": "", //address
"user_info10": "", //instagram name
"user_info12": "", //instagram link
"user_info16": "", //zalo name
"follower_id": 0,
"updated_at": 0, //Time in millis
"created_at": 0, //Time in millis
"addition_fields":
[
{
"id": 0, //id trường động
"field": "addition_field1", //Mã trường động
"label": "", //Tên trường động
"type": 0|1|2|3|4|6|7, //String|Number|DateTime|SingleSelect|MultiSelect|TextArea|Stage
"value": "", //value in string
"value_id": 0 //value id
}
]
}
}
Sự kiện người dùng
// Sự kiện cập nhật người dùng
{
"object": "user",
"action": "update",
"user": {
"id": 0,
"username": "",
"account_id": 0,
"email": "",
"email2": "",
"phone_no": "",
"phone_no2": "",
"phone_no3": "",
"role_id": 3,
"facebook": "",
"note": "",
"gender": 0,
"organization_id": 0,
"detail": "",
"avatar": "",
"user_info1": "", //facebook name
"user_info5": "", //address
"user_info10": "", //instagram name
"user_info12": "", //instagram link
"user_info16": "", //zalo name
"follower_id": 0,
"updated_at": 0, //Time in millis
"created_at": 0, //Time in millis
"addition_fields":
[
{
"id": 0, //id trường động
"field": "addition_field1", //Mã trường động
"label": "", //Tên trường động
"type": 0|1|2|3|4|6|7, //String|Number|DateTime|SingleSelect|MultiSelect|TextArea|Stage
"value": "", //value in string
"value_id": 0 //value id
}
]
}
}

2.2. Sự kiện trên tổ chức

Tổ chức
// Sự kiện tổ chức được tạo
{
"object": "organization",
"action": "create",
"organization": {
"organization_id": 0,
"account_id": 0,
"organization_name": "",
"organization_domain": "",
"details": "",
"note": "",
"created_at": 0, //Time in millis
"updated_at": 0, //Time in millis,
"addition_fields":
[
{
"id": 0, //id trường động
"field": "addition_field1", //Mã trường động
"label": "", //Tên trường động
"type": 0|1|2|3|4|6|7, //String|Number|DateTime|SingleSelect|MultiSelect|TextArea|Stage
"value": "", //value in string
"value_id": 0 //value id
}
]
}
}
Tổ chức
// Sự kiện tổ chức được cập nhật
{
"object": "organization",
"action": "update",
"organization": {
"organization_id": 0,
"account_id": 0,
"organization_name": "",
"organization_domain": "",
"details": "",
"note": "",
"created_at": 0, //Time in millis
"updated_at": 0, //Time in millis,
"addition_fields":
[
{
"id": 0, //id trường động
"field": "addition_field1", //Mã trường động
"label": "", //Tên trường động
"type": 0|1|2|3|4|6|7, //String|Number|DateTime|SingleSelect|MultiSelect|TextArea|Stage
"value": "", //value in string
"value_id": 0 //value id
}
]
}
}

2.3. Sự kiện trên phiếu ghi

Khi có sự kiện xảy ra trên phiếu ghi, nguồn của sự kiện này sẽ phân biệt bằng giá trị của thuộc tính source trong ticket_comment.
Ví dụ để phân biệt sự kiện là cuộc gọi vào hay cuộc gọi ra:
Các giá trị source cuộc gọi vào: Voice, IVR, ZCC In, MissCall, VoiceMail, Voicemail
Các giá trị source cho gọi ra: Voice Out, ZCC Out, Voice Campaign
Xem đầy đủ danh sách các giá trị của nguồn tại Danh sách nguồn.
Phiếu ghi
// Phiếu ghi được tạo
{
"object": "ticket",
"action": "create",
"ticket": {
"ticket_id": 0,
"ticket_no": 0,
"assignee_id": 0,
"service_id": 0,
"ticket_priority": "normal",
"ticket_source": "web",
"ticket_source_end_status": 0,
"ticket_status": "open",
"ticket_subject": "",
"created_at": 0, //Time in millis
"updated_at": 0, //Time in millis,
"last_change_status_at": 0, //Time in millis
"campaignId": 0,
"addition_fields":
[
{
"id": 0, //id trường động
"field": "addition_field1", //Mã trường động
"label": "", //Tên trường động
"type": 0|1|2|3|4|6|7, //String|Number|DateTime|SingleSelect|MultiSelect|TextArea|Stage
"value": "", //value in string
"value_id": 0 //value id
}
]
"ticket_comment":
{
"ticket_id": 0,
"comment": "",
"addition_details": "",
"commentator_id": 0,
"source": "web",
"is_public": 0,
"type": 0,
"created_at": 0, //Time in millis
"updated_at": 0, //Time in millis,
}
}
}
Phiếu ghi
// Phiếu ghi được cập nhật
{
"object": "ticket",
"action": "update",
"ticket": {
"ticket_id": 0,
"ticket_no": 0,
"assignee_id": 0,
"service_id": 0,
"ticket_priority": "normal",
"ticket_source": "web",
"ticket_source_end_status": 0,
"ticket_status": "open",
"ticket_subject": "",
"created_at": 0, //Time in millis
"updated_at": 0, //Time in millis,
"last_change_status_at": 0, //Time in millis
"campaignId": 0,
"addition_fields":
[
{
"id": 0, //id trường động
"field": "addition_field1", //Mã trường động
"label": "", //Tên trường động
"type": 0|1|2|3|4|6|7, //String|Number|DateTime|SingleSelect|MultiSelect|TextArea|Stage
"value": "", //value in string
"value_id": 0 //value id
},
{
}
]
"ticket_comment":
{
"ticket_id": 0,
"comment": "",
"addition_details": "",
"commentator_id": 0,
"source": "web",
"is_public": 0,
"type": 0,
"created_at": 0, //Time in millis
"updated_at": 0, //Time in millis,
}
},
"call_info": //Thông tin cuộc gọi nếu có
{
"call_id": "",
"caller": "", //SĐT khách hàng
"called": "", //Đầu số
"status_code": "200",
"start_time": 000 //Time in millis
"answer_time": 000 //Time in millis
"end_time": 000 //Time in millis
}
}
// Phiếu bị bị xoá
{
"object": "ticket",
"action": "delete",
"ticket": {
"ticket_id": 0
}
}
Phiếu ghi
// Phiếu ghi bị ghép
{
"object": "ticket",
"action": "merge",
"mergeOption":
{
"primaryTicket": 0,
"secondaryTickets": 1,
"primaryComment": "",
"primaryIsPublic": 0,
"secondaryComment": "",
"secondaryIsPublic": 0,
"addCC": 0,
"addFollow": 0,
"copyComments": 0,
}
}

2.4. Sự kiện trên SmartDialer

SmartDialer
// Cuộc gọi kết thúc từ chiến dịch auto call
{
"object": "smart_dialer",
"action": "ad_end_call",
"call_info": {
"call_id": "",
"line": "",
"phone_number": "",
"call_attempt_index": 0,
"max_attempt": 1,
"campaign_id": 0,
"customer_id": 0,
"customer_name": "",
"campaign_data_id": 0,
"start_time": 0, //Time in millis
"connect_time": 0, //Time in millis
"end_time": 0, //Time in millis
"ring_customer_duration": 0, //seconds
"call_duration": 0, //seconds
"status_code": "",
"customer_input_dtmf": "", //dữ liệu bấm phím ivr nếu có
}
}
SmartDialer
//Cuộc gọi kết thúc từ chiến dịch predictive call
{
"object": "smart_dialer",
"action": "pd_end_call",
"call_info": {
"call_id": "",
"line": "",
"phone_number": "",
"call_attempt_index": 0,
"max_attempt": 1,
"campaign_id": 0,
"customer_id": 0,
"customer_name": "",
"campaign_data_id": 0,
"start_time": 0, //Time in millis
"connect_time": 0, //Time in millis
"end_time": 0, //Time in millis
"ring_customer_duration": 0, //seconds
"call_duration": 0, //seconds
"agent_user_id": 0,
"agent_id": 0,
"agent_ring_time": 0, //Time in millis
"agent_connect_time": 0, //Time in millis
"ring_agent_duration": 0, //seconds
"status_code": ""
}
}

2.5. Sự kiện chi tiết xảy ra trên cuộc gọi vào

Đăng ký nhận sự kiện này nếu bạn muốn tích hợp chi tiết tất cả các sự kiện xảy ra trong quá trình gọi vào từ lúc cuộc gọi bắt đầu, tới lúc đổ chuông chuyên viên và kết thúc cuộc gọi.
Cuộc gọi vào
//1. Sự kiện bắt đầu cuộc gọi
{
"object": "call_in",
"action": "call_in_start",
"call_info":
{
"event_name": "call_in_start",
"call_id": "",
"account_id": 0,
"direction": "inbound",
"caller": "", //SĐT khách hàng
"called": "", //Đầu số
"event_time": 000 //Time in millis
}
}
Cuộc gọi vào
//2. Sự kiện đổ chuông tới Agent
{
"object": "call_in",
"action": "call_in_agent_ring",
"call_info":
{
"event_name": "call_in_agent_ring",
"call_id": "",
"account_id": 0,
"direction": "inbound",
"caller": "", //SĐT khách hàng
"called": "", //Đầu số
"agent_id": "",
"event_time": 000 //Time in millis
}
}
Cuộc gọi vào
//3. Sự kiện trượt qua Agent
{
"object": "call_in",
"action": "call_in_agent_miss",
"call_info":
{
"event_name": "call_in_agent_miss",
"call_id": "",
"account_id": 0,
"direction": "inbound",
"caller": "", //SĐT khách hàng
"called": "", //Đầu số
"agent_id": "",
"event_time": 000 //Time in millis
}
}
Cuộc gọi vào
//4. Sự kiện Agent bắt máy
{
"object": "call_in",
"action": "call_in_agent_answer",
"call_info":
{
"event_name": "call_in_agent_answer",
"call_id": "",
"account_id": 0,
"direction": "inbound",
"caller": "", //SĐT khách hàng
"called": "", //Đầu số
"agent_id": "",
"event_time": 000 //Time in millis
}
}
Cuộc gọi vào
//5. Sự kiện Agent kết thúc cuộc gọi
{
"object": "call_in",
"action": "call_in_agent_end",
"call_info":
{
"event_name": "call_in_agent_end",
"call_id": "",
"account_id": 0,
"direction": "inbound",
"caller": "", //SĐT khách hàng
"called": "", //Đầu số
"agent_id": "",
"event_time": 000 //Time in millis
}
}
Cuộc gọi vào
//6. Sự kiện Khách hàng kết thúc cuộc gọi
{
"object": "call_in",
"action": "call_in_customer_end",
"call_info":
{
"event_name": "call_in_customer_end",
"call_id": "",
"account_id": 0,
"direction": "inbound",
"caller": "", //SĐT khách hàng
"called": "", //Đầu số
"agent_id": "",
"event_time": 000 //Time in millis
}
}
Cuộc gọi vào
//7. Sự kiện cuộc gọi kết thúc
{
"object": "call_in",
"action": "call_in_end",
"call_info":
{
"event_name": "call_in_end",
"call_id": "",
"account_id": 0,
"direction": "inbound",
"caller": "", //SĐT khách hàng
"called": "", //Đầu số
"agent_id": "",
"event_time": 000 //Time in millis
"call_start_time": 0, //Time in millis
"call_answer_time": 0, //Time in millis
"call_end_time": 0, //Time in millis
"call_end_time": 0, //Time in millis
"call_duration": 0, //Time in seconds
"status": "answered|miss", //Trạng thái gặp agent hay không
"answer_duration": 0, //Time in seconds - status answered
"record_url": "" //Link file ghi âm - status answered
}
}

III. Mô tả tham số

1. Tham số phân loại sự kiện

Tham số
Mô tả
Giá trị
object
Loại đối tượng
ticket: Phiếu ghi user: Khách hàng organization: Tổ chức smart_dialer: Smartdialer call_in: Cuộc gọi vào
action
Hành động
Các loại sự kiện xảy ra trên đối tượng: Ví dụ: create: Tạo mới
update: Cập nhật
delete: Xóa
ad_end_call: Kết thúc cuộc gọi AutoCall của SmartDialer pd_end_call: Kết thúc cuộc gọi PredictiveCall của SmartDialer,

2. Tham số phiếu ghi ticket

Tham số
Mô tả
Giá trị
ticket_id
ID phiếu ghi
ticket_no
Số phiếu ghi
requester_id
ID người yêu cầu
assignee_id
ID người xử lý
service_id
ID dịch vụ
ticket_priority
Độ ưu tiên
High, Low, Normal
ticket_source
Nguồn phiếu ghi
Các giá trị từ Danh sách nguồn
ticket_source_end_status
Trạng thái kết thúc phiếu
ticket_status
Trạng thái phiếu ghi
new, open, pending, closed, solved
ticket_subject
Tiêu đề phiếu ghi
addition_fields
Trường động phiếu ghi.
Định dạng json array. VD: [{id:1234, field:addition_field1", label: "Tên trường động", value: "Giá trị dạng text"},...]
created_at
Thời điểm tạo phiếu ghi
updated_at
Thời điểm cập nhật phiếu ghi

3. Tham số comment phiếu ghi ticket.ticket_comment

Tham số
Mô tả
ticket_id
ID phiếu ghi
commentator_id
ID người comment
source
Nguồn comment
is_public
Loại comment: Công khai (1) hoặc ghi chú nội bộ (0).
created_at
Thời điểm comment
updated_at
Thời điểm update comment

4. Tham số cuộc gọi call_info

Đối với cuộc gọi thông thường object cuộc gọi sẽ là ticket
Tham số
Mô tả
caller
SĐT khách hàng
called
Hotline tổng đài
call_id
ID cuộc gọi
start_time
Thời điểm bắt đầu cuộc gọi
answer_time
Thời điểm bắt máy
end_time
Thời điểm kết thúc
status_code
Mã trạng thái cuộc gọi

5. Tham số người dùng user

Tham số người dùng
Mô tả
Giá trị
username
Tên người dùng
email
Email chính
email2
Email phụ
phone_no
SĐT chính
phone_no2
SĐT phụ 2
phone_no3
SĐT phụ 3
note
Ghi chú
gender
Giới tính (0 - Nam, 1 - Nữ, 2 - Khác)
organization_id
ID tổ chức
detail
Mô tả
avatar
Đường dẫn ảnh đại diện
user_info5
Địa chỉ
addition_fields
Trường động người dùng
Định dạng json array. VD: [{id:1234, field:addition_field1", label: "Tên trường động", value: "Giá trị dạng text"},...]
follower_id
ID nhân viên xử lý
created_from
Nguồn tạo KH
city_id
ID tỉnh / thành phố
district_id
ID quận / huyện

6. Tham số tổ chức organization

Tham số tổ chức (organization)
Mô tả
Ghi chú
organization_id
ID tổ chức
organization_name
Tên tổ chức
organization_domain
Website
details
Chi tiết
note
Ghi chú
addition_fields
Trường động tổ chức
Định dạng json array. VD: [{id:1234, field:addition_field1", label: "Tên trường động", value: "Giá trị dạng text"},...]

7. Tham số cuộc gọi SmartDialer call_info

Đối với cuộc gọi smart dialer. Khi object trả về "smart_dialer" thì dữ liệu đối tượng call_info theo thông tin mô tả dưới đây.
Tham số
Mô tả
campaign_id
ID chiến dịch
customer_id
ID khách hàng
customer_name
Tên khách hàng
campaign_data_id
ID Data
call_id
Mã cuộc gọi
line
Đầu số gọi ra
phone_number
SĐT nhận cuộc gọi
call_attempt_index
Số lần retry hiện tại
max_attempt
Số lần retry tối đa
start_time
Thời điểm bắt đầu cuộc gọi (millis)
connect_time
Thời điểm bắt máy
end_time
Thời điểm kết thúc
ring_customer_duration
Thời gian đổ chuông (giây)
call_duration
Thời lượng cuộc gọi (giây)
status_code
Mã lỗi cuộc gọi (Thành công = 200)
customer_input_dtmf
Dữ liệu bấm phím (nếu cuộc gọi là IVR)
agent_user_id
ID chuyên viên (Cuộc gọi predictive call - object = pd_end_call)
agent_id
IP Phone chuyên viên (Cuộc gọi predictive call)
agent_ring_time
Thời điểm đổ chuông tới chuyên viên (Preditive call)
agent_connect_time
Thời điểm kết nối tới chuyên viên (Predictive call)
ring_agent_duration
Thời lượng chuông tới chuyên viên (Predictive call)

IV. Mẫu sự kiện

1. Ticket Cuộc gọi vào nhỡ

{
"account_id": 9999,
"ticket": {
"ticket_status": "new",
"ticket_subject": "Cuộc gọi nhỡ từ 0889999999",
"ticket_priority": "Normal",
"ticket_source": "Voice",
"created_at": 1633489861000,
"ticket_id": 9999,
"updated_at": 1633489912859,
"ticket_comment": {
"updated_at": 1633489912859,
"commentator_id": 666,
"is_public": 1,
"created_at": 1633489861017,
"comment": "<b>Cuộc gọi vào<\/b><br/>ID cuộc gọi: 20211006101009-HRFZNHMV-9999<br/>Số điện thoại gọi tới: 0889999999<br/>Đầu số gọi: 1019002267<br/>Dịch vụ: Gọi vào 1999999- Gặp NV hỗ trợ<br/>Thời gian bắt đầu: 2021-10-06 10:11:00<br/>Thời gian kết thúc: 2021-10-06 10:11:52<br/>Thời gian gọi: 00:00:51<br/>Cuộc gọi bị nhỡ",
"source": "MissCall",
"ticket_id": 9999,
"type": 0
},
"ticket_no": 888,
"ticket_source_end_status": 1,
"service_id": 9999,
"requester_id": 999,
"assignee_id": -1
},
"action": "update",
"call_info": {
"answer_time": 0,
"start_time": 1633489860000,
"caller": "0889999999",
"status_code": 0,
"called": "1999999",
"end_time": 1633489912861,
"call_id": "20211006101009-HRFZNHMV-9999"
},
"object": "ticket"
}

2. Cuộc gọi vào IVR (Không chuyển ACD):

{
"account_id": 9999,
"ticket": {
"ticket_status": "new",
"updated_at": 1633488353675,
"ticket_comment": {
"updated_at": "Wed Oct 06 09:45:53 ICT 2021",
"commentator_id": 123391762,
"created_at": "Wed Oct 06 09:45:53 ICT 2021",
"comment": "Cuộc gọi vào IVR <\/br>Số gọi đến: 0889999999<\/br>Đầu số: 19009999<\/br>Id cuộc gọi: 20211006094514-HRFZNHMV-9999<\/br>Thời gian bắt đầu: 2021-10-06 09:45:14<\/br>Thời gian kết thúc: 2021-10-06 09:45:53<\/br>NodeName: Gọi vào<\/br>Dtmf: -2-#",
"source": "IVR",
"ticket_id": 259312810,
"type": 0
},
"ticket_subject": "Cuộc gọi vào IVR từ : 0889999999",
"ticket_no": 45028,