WhatsApp API
createWhatsAppMessage เลิกใช้งานแล้ว
Anchor link toใช้สำหรับส่งข้อความ WhatsApp ไปยังผู้ใช้
POST https://api.pushwoosh.com/json/1.3/createWhatsAppMessage
เนื้อหาของคำขอ
Anchor link to| ชื่อ | จำเป็น | ประเภท | คำอธิบาย |
|---|---|---|---|
| auth* | ใช่ | string | API access token จาก Pushwoosh Control Panel |
| application* | ใช่ | string | รหัสแอปพลิเคชัน Pushwoosh |
| notifications* | ใช่ | array | การตั้งค่าเนื้อหา อาร์เรย์ JSON ของพารามิเตอร์ข้อความ ดูรายละเอียดด้านล่าง |
พารามิเตอร์การแจ้งเตือน
Anchor link to| ชื่อ | จำเป็น | ประเภท | คำอธิบาย |
|---|---|---|---|
| send_date* | ใช่ | string | วันที่และเวลาที่จะส่งการแจ้งเตือน ใช้รูปแบบ YYYY-MM-DD HH:mm หรือ 'now' เพื่อส่งทันที |
| content | จำเป็นหากไม่ได้ระบุ content_id | string | เนื้อหาข้อความของ WhatsApp |
| content_id | จำเป็นหากไม่ได้ระบุ content | string | ตัวระบุสำหรับเทมเพลต WhatsApp ที่ได้รับการอนุมัติล่วงหน้าจากบัญชี Meta ของคุณ |
| devices* | ใช่ | array | หมายเลขโทรศัพท์ของลูกค้า (ต้องเชื่อมโยงกับ User ID โดยใช้ /registerDevice และระบุในพารามิเตอร์ hwid หรือใช้ use_auto_registration) สามารถระบุได้เพียงหมายเลขเดียวที่นี่ |
| use_auto_registration | ไม่ | boolean | หากตั้งค่าเป็น true หมายเลขโทรศัพท์ที่ระบุในพารามิเตอร์ devices จะถูกลงทะเบียนโดยอัตโนมัติ |
| content_variables | ไม่ | object | ตัวแปรเนื้อหาเพื่อปรับแต่งเนื้อหาข้อความ ตัวยึดตำแหน่งแต่ละตัวจะถูกแทนที่ด้วยค่าไดนามิกที่สอดคล้องกัน |
| button_url_variables | ไม่ | object | ตัวแปร URL แบบไดนามิกสำหรับปุ่ม แต่ละคีย์แสดงถึงดัชนีของปุ่ม และค่าของมันคือตัวแปรไดนามิกที่จะแทนที่ใน URL ของปุ่ม หมายเหตุ: การจัดทำดัชนีปุ่มเริ่มต้นที่ 0 โดยปุ่มแรกคือ 0 ปุ่มที่สองคือ 1 และต่อไปเรื่อยๆ |
| header_variables | ไม่ | object | ตัวแปรสำหรับส่วนหัวในข้อความเทมเพลต WhatsApp ระบุ type (เช่น text, image, video, document) และค่าที่สอดคล้องกัน ตัวอย่าง: "header_variables": {"image": "https://image-url.png"} |
| preset | ไม่ | string | รหัส Preset ของ WhatsApp จาก Control Panel ของคุณ |
| language | ไม่ | string | โลแคลภาษาของเทมเพลต WhatsApp (ต้องตรงกับโลแคลในตัวแก้ไขเทมเพลต Meta WhatsApp) ค่าเริ่มต้น: "en_US" ตัวอย่าง: "en_GB" |
ตัวอย่างคำขอ
Anchor link to{ "request": { "application": "12XXX-67XXX", // required. Pushwoosh application code. "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel. "notifications": [{ "send_date": "now", // required. YYYY-MM-DD HH:mm OR "now". "content": "Hello! {{1}}", // required if content_id is not provided. Message text. "content_id": "hello_world", // required if content is not provided. WhatsApp template identifier. "devices": ["whatsapp:+1234567890"], // required. Customer WhatsApp phone number (must be associated // with a UserId using /registerDevice and specified in // the "hwid" parameter or use "use_auto_registration"). // Only one WhatsApp number can be specified here. "preset": "XXXXX-XXXXX", // optional. WhatsApp Preset Code from your Control Panel. "content_variables": { // optional. Content variables to customize the message content. "1": "John" }, "header_variables": { // optional. Variables for the WhatsApp message header. "image": "https://image-url.png" }, "language": "en_GB", // optional. Language locale for the WhatsApp template (must match the locale in Meta WhatsApp template editor). Default: "en_US". "use_auto_registration": true // optional. Automatically register WhatsApp number specified // in "devices" parameter. }] }}ตัวอย่าง: การส่งรหัสยืนยันตัวตนสองปัจจัยผ่าน WhatsApp
Anchor link to{ "request": { "application":"APP_CODE", "auth":"AUTH_TOKEN", "notifications":[{ "send_date":"now", "content_id":"replace_with_your_meta_two_factor_template_name", "content_variables":{"1":"AUTH_CODE"}, "button_url_variables":{"0":"AUTH_CODE"}, "devices":["whatsapp:REPLACE_WITH_YOUR_PHONE_NO"] }] }}ตัวอย่างการตอบกลับ
Anchor link to{ "status_code": 200, "status_message": "OK", "response": { "Messages": [ "9648-0B10EXXX-0D9F2XXX" ] }}การตอบกลับข้อผิดพลาด
Anchor link to{ "status_code": 210, "status_message": "Invalid devices list. \"devices\" must be an array.", "response": { "Messages": [] }}