Chuyển tới nội dung chính

Gửi tin nhắn dạng sticker đến người dùng ẩn danh

Lưu ý

Quyền cần có: Quyền gửi tin và thông báo qua OA

HTTP request​

Example request​

curl \
-X POST \
-H 'Content-Type: application/json' \
-H 'access_token: <your_access_token>' \
-d '{
"recipient": {
"anonymous_id": "5443873f256ecc30957f",
"conversation_id": "2c298a21b4645d3a0475"
},
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "media",
"elements": [{
"media_type": "sticker",
"attachment_id": "bfe458bf64fa8da4d4eb"
}[]
}
}
}
}' "https://openapi.zalo.me/v2.0/oa/message"

Tham số header​

Tham sốKiểu dữ liệuTính bắt buộcMô tả
access_token

string

yes

Token cho phép ứng dụng đại diện OA gọi API. Xem chi tiết cách lấy access token tại đây.

Cấu trúc body của request​

Tham sốKiểu dữ liệuTính bắt buộcMô tả

recipient

object

yes

Thông tin người nhận

message

object

yes

Nội dung cần gửi

Cấu trúc thuộc tính recipient​

Tham sốKiểu dữ liệuTính bắt buộcMô tả

anonymous_id

string

yes

Id đại diện cho người dùng ẩn danh.

conversation_id

string

yes

Id của cuộc hội thoại.

Cấu trúc thuộc tính message​

Tham sốKiểu dữ liệuTính bắt buộcMô tả

attachment

object

yes

Attachment cần gửi.

Cấu trúc thuộc tính message.attachment​

Tham sốLoạiTính bắt buộcMô tả

type

string

yes

Loại attachment.

Giá trị nhận vào bắt buộc:

  • type = template

payload

object

yes

Chứa payload của attachment muốn gửi.

Cấu trúc thuộc tính message.attachment.payload​

Tham sốKiểu dữ liệuTính bắt buộcMô tả

template_type

string

yes

Loại template
Với template gửi thông báo theo mẫu đính kèm ảnh, giá trị nhận vào là:
template_type = media

elements

array

yes

Các đối tượng của template.

Lưu ý: Cấu trúc element thay đổi tùy theo loại template. Với template media, danh sách element bao gồm tối đa 1 phần tử.

Cấu trúc thuộc tính message.attachment.payload.element​

Tham sốKiểu dữ liệuTính bắt buộcMô tả
media_type

string

yes

Nhận vào giá trị: sticker
attachment_id

array

yes

Truyền vào stricker lấy từ nguồn:https://stickers.zaloapp.com/ Xem video: https://vimeo.com/649330161

Example respond​

{
"data": {
"message_id": "92abd4e6156c8333da7c",
"anonymous_id": "1ffedc467f179649cf06",
"conversation_id": "fa8f3f8701c2e89cb1d3"
},
"error": 0,
"message": "Success"
}

Cấu trúc thuộc tính data​

Thuộc tínhKiểu dữ liệuMô tả

message_id

string

Id của tin nhắn.

anonymous_id

string

Id đại diện người dùng ẩn danh.

conversation_id

string

Id của cuộc hội thoại.