Help Center การอนุญาตผู้ดำเนินการและลิงก์ลึก

การอนุญาตผู้ดำเนินการและลิงก์ลึก

คู่มือนี้อธิบายวิธีการรับโทเค็นการอนุญาตที่ถูกต้องสำหรับผู้ดำเนินการในระบบผ่าน API และวิธีการใช้ลิงก์ลึกเพื่อไปยังแผงแชท

URL พื้นฐานของ API: https://chatapi.smsbat.com/ Swagger: https://chatapi.smsbat.com/index.html

หมายเหตุ: คุณสามารถใช้หัวข้อ X-Authorization-Key พร้อมโทเค็นของคุณ (ที่สามารถดูได้ในโปรไฟล์ของคุณในแดชบอร์ด) แทนการอนุญาตแบบ Bearer สำหรับคำขอระดับบริษัท


1. รับโทเค็นบริษัท

เพื่อรับโทเค็นบริษัท ส่งคำขอ HTTP POST ไปที่ /api/company/get-token พร้อมข้อมูลประจำตัวการเข้าสู่ระบบของบริษัท

คำขอ

  • วิธี: POST
  • URL: https://chatapi.smsbat.com/api/company/get-token
  • Headers: Content-Type: application/json

Body:

{
  "login": "string",
  "password": "string"
}

Response

  • Status Code: 200 (OK)
  • Body: สตริงโทเค็น ("your_token_string")

หมายเหตุ: บันทึกโทเค็นที่ได้รับเพื่อใช้ในคำขอถัดไป


2. ดึงรายการองค์กร

ส่งคำขอ GET ไปที่ /api/company/organization โดยใช้โทเค็นบริษัทเพื่อแสดงรายการองค์กรของคุณ

คำขอ

  • วิธี: GET
  • URL: https://chatapi.smsbat.com/api/company/organization
  • Headers:
    • Authorization: Bearer {token}
    • Accept: text/plain

Response

  • Status Code: 200 (OK)
  • Body:
[
  {
    "id": 6,
    "name": "string"
  }
]

3. Retrieve Operators by Organization

Send a GET request to /api/operator using the organizationId parameter.

Request

  • Method: GET
  • URL: https://chatapi.smsbat.com/api/operator?organizationId={id}
  • Headers:
    • Authorization: Bearer {token}
    • Accept: text/plain

Response

  • Status Code: 200 (OK)
  • Body:
[
  {
    "id": 21,
    "name": "string",
    "status": 1,
    "organization": {
      "id": 24,
      "name": "test_costs"
    }
  }
]

4. Add Operators to the System

Use the company token to access this endpoint and synchronize operators to the system.

Request

  • Method: POST
  • URL: https://chatapi.smsbat.com/api/operator/synchronize
  • Headers:
    • Authorization: Bearer {token}
    • Content-Type: application/json

เนื้อหา:

[
  {
    "organizationId": 24,
    "name": "string"
  }
]

การตอบกลับ

  • รหัสสถานะ: 200 (OK)
  • เนื้อหา:
[
  {
    "id": 21,
    "status": 0,
    "name": "string"
  }
]

สถานะผู้ปฏิบัติงานที่เป็นไปได้:

  • เปิดใช้งาน: 0
  • ไม่เปิดใช้งาน: 1
  • ถูกลบ: 2

5. รับโทเค็นผู้ปฏิบัติงาน

Authorize ด้วยโทเค็นของบริษัทเพื่อรับโทเค็นสำหรับผู้ปฏิบัติงานเฉพาะ

คำขอ

  • วิธี: POST
  • URL: https://chatapi.smsbat.com/api/operator/get-token
  • หัวเรื่อง:
    • Authorization: Bearer {token}
    • Content-Type: application/json

เนื้อหา:

{
  "id": 0,
  "expiresAt": "2025-01-20T14:33:34.147Z"
}

expiresAt จำเป็นและกำหนดระยะเวลาการเชื่อมต่อของผู้ปฏิบัติงาน (สูงสุด +24 hours).

การตอบกลับ

  • รหัสสถานะ: 200 (OK)
  • เนื้อหา: String token

6. ตรวจสอบความถูกต้องของโทเค็นผู้ปฏิบัติงาน

ตรวจสอบความถูกต้องของโทเค็นของผู้ปฏิบัติงาน.

คำขอ

  • Method: POST
  • URL: https://chatapi.smsbat.com/api/operator/validate-token
  • Headers:
    • Authorization: Bearer {token}
    • Content-Type: application/json

Body: "operator_token_string"

Valid Response (200 OK):

{
  "isValid": true,
  "operatorId": 0,
  "clientId": 0,
  "expiresAt": "2024-12-28T14:04:15.861Z",
  "error": null
}

7. การลิงก์เชิงลึกไปยังแผงแชทของผู้ปฏิบัติงาน

ระบบภายนอก (CRM, ERP, เว็บไซต์ภายใน) สามารถเปิดแผงแชทโดยตรงโดยใช้ลิงก์เชิงลึกโดยส่ง JWT Operator token เป็นพารามิเตอร์ หากโทเค็นไม่ถูกต้องหรือหมดอายุ ผู้ใช้จะถูกเปลี่ยนเส้นทางไปยังหน้าล็อกอิน

Format 1: ตาม Chat ID

https://chat.smsbat.com/?chat_raw_id=<chat_id>&token=<jwt_token>

Format 2: ตามหมายเลขโทรศัพท์

https://chat.smsbat.com/?phone=<phone_number>&token=<jwt_token>

หมายเลขโทรศัพท์ต้องอยู่ในรูปแบบสากล E.164.

Format 3: ตาม Alpha Name & Phone

https://chat.smsbat.com/?from=<bm_id>&phone=<phone_number>&token=<jwt_token>

Format 4: รายละเอียดเป้าหมายครบถ้วน

ระบุอย่างชัดเจนว่าต้องดักจับข้อความจากแหล่งใด:

https://chat.smsbat.com/?source=<sourceId>&from=<bm_id>&phone=<phone_number>&token=<jwt_token>

Chat Sources:

  • 0 - Viber
  • 1 - ViberBot
  • 2 - TelegramBot
  • 3 - Whatsapp
  • 4 - Widget
  • 5 - Rozetka
  • 6 - Facebook
  • 7 - Instagram