Help Center การเชื่อมต่อ Telegram Bot

การเชื่อมต่อ Telegram Bot

คู่มือนี้อธิบายวิธีเชื่อมต่อ Telegram Bot ของคุณกับแผงควบคุม chat.smsbat.com

1. การเพิ่มบอทในแผงควบคุม

ในแดชบอร์ด ไปที่ บัญชีของฉัน -> Telegram bots

  1. คลิก เพิ่มบอท
  2. กรอกข้อมูล Telegram bot (ชื่อ, โทเคน) แล้วบันทึกในระบบ
  3. หลังจากบันทึกแล้ว ให้ไปที่การตั้งค่าของบอทและดู ID เพื่อนำไปสร้าง callback URL

2. ตัวเลือกการเชื่อมต่อกับ Chat.SMSBAT

ตัวเลือกที่ 2.1: การพร็อกซี callback จาก Telegram ไปยัง Omni Chat

ในรูปแบบนี้ เซิร์ฟเวอร์ของคุณจะรับ webhook จาก Telegram โดยตรง จากนั้นส่งต่อ payload ไปยัง SMSBAT

sequenceDiagram
    participant Client as Client Server
    participant Tg as Telegram
    participant Proxy as SMSBAT Proxy
    participant Chat as Omni Chat
    actor Operator
    
    Client->>Tg: Send data to bot
    Tg->>Client: Callback from Telegram
    Client->>Proxy: Forward Telegram callback to SMSBAT
    Proxy->>Chat: Reaction to trigger message
    Operator->>Chat: Review and respond
    Chat->>Tg: Interaction with Telegram

ข้อกำหนด:

  • ตรวจสอบให้แน่ใจว่าระบบของลูกค้าพร็อกซี callback ที่เข้ามาไปยัง webhook ของ chat.smsbat.com โดยตรง
  • ระบุข้อความ/การดำเนินการที่ตรงกันของปุ่ม “เริ่มแชท”
  • ระบุข้อความ/การดำเนินการที่ตรงกันของปุ่ม “จบแชท”

ตัวเลือกที่ 2.2: การพร็อกซีตรรกะกลับไปยังฝั่งลูกค้า

ในรูปแบบนี้ SMSBAT ถูกตั้งเป็น webhook โดยตรงใน Telegram SMSBAT จะรับเหตุการณ์ แล้วพร็อกซี callback กลับไปยังระบบของคุณ

sequenceDiagram
    participant Client as Client Server
    participant Tg as Telegram
    participant Proxy as SMSBAT Proxy
    participant Chat as Omni Chat
    actor Operator
    
    Client->>Tg: Send data to bot
    Tg->>Proxy: Callback on events from Telegram
    Proxy->>Client: Forward Telegram callback to Client
    Proxy->>Chat: Reaction to trigger message
    Operator->>Chat: Review and respond
    Chat->>Tg: Operator interaction with Telegram

ข้อกำหนด:

  • ระบุ callback URL ที่สร้างขึ้นหลังจากเพิ่มบอท URL จะมีลักษณะดังนี้: https://restapi.smsbat.com/api/tg_callback/{ID}
  • ระบุข้อความ/การดำเนินการที่ตรงกันของปุ่ม “เริ่มแชท”
  • ระบุข้อความ/การดำเนินการที่ตรงกันของปุ่ม “จบแชท”