Get Chatroom
ขอห้องแชท HumanSoft Connect ของพนักงานหนึ่งคน เพื่อนำ chat_id และ sender_chat_user_id ไปใช้ส่งข้อความด้วย Send Message
Endpoint
GET /api/v1/open-apis/hms-connect/get-chatroomสิทธิ์ที่ต้องการ: API Key ต้องมีสิทธิ์ การส่งข้อความ HumanSoft Connect (connect:send)
Request Parameters
ส่งเป็น query string เท่านั้น (ระบบไม่อ่านค่าจาก request body) หากรหัสพนักงานมีอักขระพิเศษให้ URL-encode ก่อน
Required Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
employee_code | string | Yes | รหัสพนักงานผู้รับข้อความ | EMP001 |
Example Request
GET /api/v1/open-apis/hms-connect/get-chatroom?employee_code=EMP001Response Format
Success Response (HTTP 200)
{
"code": 200,
"message": "Success",
"payload": {
"chat_id": "20251127D4573C421639",
"sender_chat_user_id": "20251127A1B2C3D4E5F6"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
chat_id | string | ID ของห้องแชท HumanSoft Connect ของพนักงาน (ค่า raw — ต้องเข้ารหัส Base64 ก่อนส่งเข้า Send Message) |
sender_chat_user_id | string | ID ของผู้ส่ง (บอทของระบบ) ประจำห้องนี้ (ค่า raw — ต้องเข้ารหัส Base64 ก่อนส่งเข้า Send Message) |
Error Response - Validation Failed (HTTP 400)
ไม่ได้ส่ง employee_code หรือส่งเป็นค่าว่าง
{
"code": 400,
"message": "Validation failed",
"errors": [
"'employee_code' query parameter is required"
]
}Error Response - Employee Not Found (HTTP 400)
ไม่พบพนักงานตาม employee_code ในบริษัทของ API Key หรือพนักงานถูกลบไปแล้ว
{
"code": 400,
"message": "Employee not found with code: EMP001"
}Error Response - No User Account (HTTP 400)
พนักงานไม่มีบัญชีผู้ใช้ HumanSoft จึงไม่มีห้องแชท
{
"code": 400,
"message": "Employee EMP001 has no HumanSoft user account, so there is no HumanSoft Connect chat room"
}Error Response - No Chat Room Yet (HTTP 400)
พนักงานยังไม่เคยเปิดเมนูแชทในแอป HumanSoft
{
"code": 400,
"message": "Employee has no HumanSoft Connect chat room yet. The employee must open the chat in the HumanSoft app first"
}Error Response - Lookup Failed (HTTP 400)
ค้นหาห้องแชทไม่สำเร็จ
{
"code": 400,
"message": "Failed to look up the HumanSoft Connect chat room. Please try again"
}Code Examples
cURL
curl -X GET "https://openapi.humansoft.co.th/api/v1/open-apis/hms-connect/get-chatroom?employee_code=EMP001" \
-H "Ocp-Apim-Subscription-Key: YOUR_API_KEY"Notes
ข้อควรทราบ:
- ค้นหาได้เฉพาะพนักงานของบริษัทที่ผูกกับ API Key เท่านั้น
- API นี้ไม่สร้างห้องแชทให้ — พนักงานต้องเปิดเมนูแชทในแอป HumanSoft อย่างน้อยหนึ่งครั้งก่อน
- ห้องแชทของพนักงานแต่ละคนเป็นห้องเดิม เก็บ
chat_idและsender_chat_user_idไว้ใช้ซ้ำได้ - ทำงานทีละพนักงาน หากต้องการส่งถึงหลายคนให้เรียกซ้ำทีละคน
- Endpoint นี้ไม่เปลี่ยนแปลงข้อมูล จึงเรียกซ้ำได้อย่างปลอดภัยเมื่อได้รับ error “Failed to look up the HumanSoft Connect chat room”
Related APIs
- Send Message - ส่งข้อความเข้าห้องแชทที่ได้จาก Endpoint นี้
- HumanSoft Connect Overview - ขั้นตอนการใช้งานและตัวอย่างครบขั้นตอน
Last updated on