เอกสารอ้างอิง API

เริ่มต้นใช้งาน

ตอบกลับข้อความที่ได้รับ

ใช้การสนทนาขาเข้าเป็นเป้าหมาย ตอบธรรมดาให้ละ reply_to ตอบแบบอ้างอิงให้คัดลอก reply_token เดิม

เริ่มต้นใช้งาน

  1. 1

    ก่อนเรียกใช้

    ทำขั้นนี้ก่อน: ความคืบหน้าการให้สิทธิ์และข้อความขาเข้าแบบ realtime มาทาง webhook โดยไม่รับประกัน replay ของ delivery ที่พลาด ["*"] subscribe public standard event ทั้งหมด ส่วน WhatsApp HistorySync ให้เพียงความต่อเนื่องล่าสุดแบบจำกัด ไม่ใช่ประวัติถาวร

    Webhook delivery & signature verification
  2. 2

    ที่มาของพารามิเตอร์

    เมื่อตอบกลับให้คัดลอก data.conversation.id และ data.conversation.type จาก message.received ไปยัง to.id และ to.type ผู้รับใหม่ต้องใช้กฎรหัสของช่องทางนั้น

    message.received
  3. 3

    ส่งข้อความตัวอักษร

    ใช้การสนทนาขาเข้าเป็นเป้าหมาย ตอบธรรมดาให้ละ reply_to ตอบแบบอ้างอิงให้คัดลอก reply_token เดิม

    curl -X POST "https://api.unifyport.ai/v1/messages" \
      -H "X-Api-Key: <YOUR_API_KEY>" \
      -H "Content-Type: application/json" \
      -d '{
      "account_id": "acc_example",
      "to": {
        "id": "user_example",
        "type": "user"
      },
      "message": {
        "type": "text",
        "text": "Hello from UnifyPort"
      }
    }'
    ส่งข้อความตัวอักษร
  4. 4

    ตอบกลับข้อความ (อ้างอิง)

    ใช้การสนทนาขาเข้าเป็นเป้าหมาย ตอบธรรมดาให้ละ reply_to ตอบแบบอ้างอิงให้คัดลอก reply_token เดิม

    curl -X POST "https://api.unifyport.ai/v1/messages" \
      -H "X-Api-Key: <YOUR_API_KEY>" \
      -H "Content-Type: application/json" \
      -d '{
      "account_id": "acc_example",
      "to": {
        "id": "8600000000000@s.whatsapp.net",
        "type": "user"
      },
      "message": {
        "type": "text",
        "text": "Sure - replying to your question above."
      },
      "reply_to": {
        "reply_token": "<data.message.reply_token from the inbound event>"
      }
    }'
    ตอบกลับข้อความ (อ้างอิง)