Connect API
Base URL: https://connect-api.pcampus.co
Connect API manages the unified inbox, chat widget, conversations, AI-suggested replies, and reward delivery in-chat.
Conversations
GET /v1/conversations
List conversations across all channels.
GET https://connect-api.pcampus.co/v1/conversations?status=open&limit=20
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-idQuery params:
| Param | Type | Description |
|---|---|---|
status | string | open | pending | resolved |
channel | string | line | facebook | web | email |
assignedTo | string | staff user ID |
limit | number | default 20, max 100 |
cursor | string | pagination cursor |
Response:
{
"data": [
{
"conversationId": "conv_xxx",
"channel": "line",
"customerId": "cust_001",
"customerName": "สมชาย จันทร์ดี",
"lastMessage": "ยา Amlodipine หมดแล้วครับ",
"lastMessageAt": "2026-07-15T10:00:00.000Z",
"status": "open",
"assignedTo": "staff-01",
"unreadCount": 2
}
],
"nextCursor": "eyJpZCI6ImNvbnZfeXl5In0="
}GET /v1/conversations/:conversationId
View a conversation thread with Customer Story.
GET https://connect-api.pcampus.co/v1/conversations/conv_xxx
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-idResponse:
{
"conversationId": "conv_xxx",
"channel": "line",
"customerId": "cust_001",
"status": "open",
"messages": [
{
"messageId": "msg_001",
"direction": "inbound",
"body": "ยา Amlodipine หมดแล้วครับ",
"sentAt": "2026-07-15T10:00:00.000Z"
}
],
"customerStory": {
"segment": "loyal",
"churnRisk": 0.12,
"lastVisit": "2026-07-12",
"topProduct": "Amlodipine 5mg",
"recommendations": [
{ "type": "reorder", "message": "เสนอสั่งซ้ำ Amlodipine 5mg 30 เม็ด" }
]
},
"suggestedReply": "ได้เลยครับ คุณสมชาย Amlodipine 5mg 30 เม็ด ราคา ฿180 จัดส่งได้วันนี้ครับ ต้องการสั่งเลยไหมครับ?"
}PATCH /v1/conversations/:conversationId
Update status or assignment.
PATCH https://connect-api.pcampus.co/v1/conversations/conv_xxx
Authorization: Bearer <pip_api_key>
{
"status": "resolved",
"assignedTo": "staff-02"
}Messages
POST /v1/conversations/:conversationId/messages
Send a reply to the customer on the same channel.
POST https://connect-api.pcampus.co/v1/conversations/conv_xxx/messages
Authorization: Bearer <pip_api_key>
{
"body": "ได้เลยครับ Amlodipine 5mg 30 เม็ด ราคา ฿180 จัดส่งได้วันนี้ครับ",
"sentBy": "staff-01",
"suggestionUsed": true
}Response:
{
"messageId": "msg_002",
"conversationId": "conv_xxx",
"channel": "line",
"direction": "outbound",
"body": "ได้เลยครับ...",
"sentAt": "2026-07-15T10:02:00.000Z",
"deliveryStatus": "sent"
}Rewards
POST /v1/conversations/:conversationId/rewards
Send a coupon or reward to the customer on the active channel.
POST https://connect-api.pcampus.co/v1/conversations/conv_xxx/rewards
Authorization: Bearer <pip_api_key>
{
"rewardType": "coupon",
"couponCode": "WINBACK10",
"description": "ส่วนลด 10% สำหรับคำสั่งซื้อถัดไป",
"validDays": 7,
"sentBy": "staff-01"
}Response:
{
"rewardId": "rwd_xxx",
"conversationId": "conv_xxx",
"customerId": "cust_001",
"rewardType": "coupon",
"couponCode": "WINBACK10",
"deliveredAt": "2026-07-15T10:03:00.000Z",
"pbcpEventId": "evt_xxx"
}The system automatically records a
reward.sent_via_chatevent back to PBCP.
Q&A Corpus
GET /v1/qa
List Q&A entries used to train the chatbot.
GET https://connect-api.pcampus.co/v1/qa
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-idPOST /v1/qa
Add a new Q&A entry.
POST https://connect-api.pcampus.co/v1/qa
Authorization: Bearer <pip_api_key>
{
"question": "ยา Amlodipine กินตอนไหนครับ",
"answer": "กินได้ทุกเวลาครับ แต่ควรกินเวลาเดิมทุกวัน เช่น หลังอาหารเช้าทุกวัน",
"tags": ["amlodipine", "วิธีกิน"],
"domain": "pharmacy"
}PATCH /v1/qa/:qaId
DELETE /v1/qa/:qaId
Widget
GET /v1/widget/config
Fetch the config used to render the widget on the client.
GET https://connect-api.pcampus.co/v1/widget/config
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-idResponse:
{
"tenantId": "pharmacy-demo",
"domain": "pharmacy",
"primaryColor": "#2563eb",
"position": "bottom-right",
"quickActions": ["ประวัติยา", "สั่งยาซ้ำ", "ปรึกษาเภสัชกร"],
"businessHours": { "open": "08:00", "close": "20:00", "timezone": "Asia/Bangkok" },
"offlineMessage": "ร้านปิดแล้วครับ จะติดต่อกลับในวันทำการถัดไป"
}Identity — External IdP Binding
POST /v1/identity/exchange
Exchange an External IdP token for a Connect session token (called automatically by the widget SDK).
POST https://connect-api.pcampus.co/v1/identity/exchange
x-tenant-id: your-tenant-id
{
"provider": "firebase",
"identityToken": "<firebase_id_token>"
}Response:
{
"sessionToken": "cses_xxx",
"expiresAt": "2026-07-15T11:00:00.000Z",
"customerId": "cust_001",
"isNewCustomer": false
}Supported providers:
provider | Configuration required in Console |
|---|---|
firebase | Firebase Project ID |
auth0 | Domain + Audience |
supabase | Project URL + JWT Secret |
custom | JWKS URI |
GET /v1/identity/providers
List External IdP providers configured for the tenant.
GET https://connect-api.pcampus.co/v1/identity/providers
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-id