1. Overview
LiveChatHub is a middleware platform that enables integration between Knovvu Virtual Assistant (Magpie) and third‑party live‑agent chat platforms such as Genesys Cloud, Amazon Connect, Twilio, Tegsoft, and others.
The system uses a provider‑based adapter architecture. Each vendor integration is implemented as a separate adapter that conforms to the ILiveChatService interface.
Core Responsibilities
| Component | Responsibility |
|---|---|
| LiveChatHub API | Entry point for Magpie, routes requests to providers |
| Provider Adapter | Translates generic requests into vendor‑specific APIs |
| Magpie Client | Sends agent events/messages back to Knovvu VA |
| Event Listener | Receives webhook callbacks from live‑agent platforms |
2. Architecture & Conversation Flow
High‑Level Flow
- Customer requests a live agent via Knovvu VA (Magpie)
- Magpie calls LiveChatHub to start a conversation
- LiveChatHub routes the request to the correct provider adapter
- Adapter creates a session on the live‑agent platform
- Messages flow bi‑directionally through LiveChatHub
- Conversation ends either by Magpie or by the agent platform
Sequence Diagram (Conceptual)
- Customer → Magpie → LiveChatHub → Provider Adapter → Agent Platform
- Agent events → Provider Adapter → LiveChatHub → Magpie → Customer
3. Authentication
Token Endpoint
POST /livechathub/connect/token/{provider}
Content‑Type: application/x-www-form-urlencoded
Parameters
| Name | Required | Description |
|---|---|---|
grant_type |
Yes | OAuth grant type (client_credentials) |
client_id |
No | Client identifier |
client_secret |
No | Client secret |
Authorization Header
Authorization: Basic base64(username:password)
Response
{
"access_token": "<jwt>",
"expires_in": 31536000,
"token_type": "Bearer",
"scope": "lc_adapter"
}
4. API Endpoints
All endpoints are available in two forms:
/livechathub/{endpoint}/{provider}/livechathub/generic/{endpoint}/{provider}
4.1 Check Agent Availability
GET /livechathub/agent/availability/{provider}
Query Parameters
| Name | Description |
|---|---|
tenantName |
Tenant identifier |
queueName |
Queue / skill name |
Response
{ "totalAgentCapacity": 1 }
4.2 Get Skills / Queues
GET /livechathub/skills/{provider}
Headers
Authorization: Bearer <token>
Query Parameters
| Name | Description |
|---|---|
tenantName |
Tenant identifier |
Response
["skill1", "skill2", "queue_name"]
4.3 Start Conversation
POST /livechathub/conversation/{provider}
Headers
Authorization: Bearer <token>
Content-Type: application/json
Query Parameters
| Name | Description |
|---|---|
url |
Vendor base API URL |
id |
Optional identifier |
skills |
Comma‑separated skills |
Request Body
- Microsoft Bot Framework
Activity - Contains customer info, conversation id, channel data, history, and summary
Response
{
"startConversationSuccess": true,
"id": "conversation-id",
"token": "session-token",
"_status": ""
}
4.4 Send Message
POST /livechathub/send-message/{provider}
Request Body
- Text message
- Optional attachments (files, images, etc.)
Response
{
"sendMessageSuccess": true,
"sendMessageError": "",
"id": "message-id"
}
4.5 Get Conversation Status
GET /livechathub/conversation/status/{provider}
Response
{ "success": true, "error": "" }
4.6 End Conversation
PUT /livechathub/conversation/{provider}
Request Body
{
"type": "endOfConversation",
"conversation": { "id": "conversation-id" }
}
5. Webhook (Event Listener)
POST /livechathub/EventListener/{provider}/{option}/
Path Parameters
| Name | Description |
|---|---|
provider |
Adapter name |
option |
Event type (message, status, typing, ended) |
Optional Query
| Name | Description |
|---|---|
conversationSuffix |
Extra vendor‑specific identifier |
Supported Events
| Event | Description |
|---|---|
| Agent Message | Agent sends text or attachment |
| Agent Joined | Agent accepts chat |
| Agent Typing | Typing indicator |
| Chat Ended | Conversation closed |
| Transfer | Chat transferred |
6. MagpieRequest Model
This object is sent from LiveChatHub to Magpie when agent events occur.
Key Fields
Text: message contentConversation.Id: full conversation identifierFrom: agent infoRecipient: customer infoType: message or event typeAttachments: optional filesChannelData: custom metadata
7. Message Types
| Type | Description |
|---|---|
message |
Regular agent message |
chatAssignedToAgent |
Agent joined |
chatAssignmentTimeout |
No agent available |
agentMessageTimeout |
Agent silent timeout |
endedByAgent |
Agent closed chat |
typing |
Typing indicator |
8. File Attachments
Supported Categories
| Category | Extensions |
|---|---|
| Image | jpg, png, gif, webp |
| Video | mp4, webm |
| Audio | mp3, wav |
| File | pdf, docx, xlsx, txt |
9. Magpie Integration Details
9.1 Authentication
- OAuth2 Client Credentials
- Token endpoint:
{Magpie.OAuthEndpoint}/connect/token - Token cached in memory and refreshed automatically
9.2 Sending Messages to Magpie
Endpoint
POST {Magpie.Endpoint}/magpie/api/messages
Required Headers (Derived from Conversation.Id)
| Header | Source |
|---|---|
X-Knovvu-Conversation-Id |
Segment 0 |
Tenant |
Segment 2 |
Project |
Segment 3+ |
9.3 Conversation ID Format (Critical)
The conversation ID must follow this format:
{conversationRootId}_{channelId}_{tenant}_{project[_subproject...]}
Example
260b3b8b-9ee4_TESTCHAT_DEFAULT_TESTHL_SUBPROJECT
Parsed As
| Segment | Value | Usage |
|---|---|---|
[0] |
Root ID | X‑Knovvu‑Conversation‑Id |
[1] |
Channel | Informational |
[2] |
Tenant | Tenant header |
[3..] |
Project | Project header |
Conversation ID must contain at least 4 underscore‑separated segments, otherwise Magpie routing will fail.
10. Conversation End Scenarios
10.1 Magpie → LiveChatHub
- Magpie calls
PUT /conversation/{provider} - Adapter disconnects vendor session
10.2 Provider → Magpie
- Agent ends chat on vendor side
- Provider receives webhook
- Adapter sends
endedByAgentevent to Magpie
11. Error Handling
| Status | Meaning |
|---|---|
| 200 | Success |
| 401 | Invalid / expired token |
| 500 | Internal error |
12. Notes & Best Practices
- Always validate webhook payloads
- Preserve the same
Conversation.Idthroughout the flow - Ensure underscore format correctness
- Send agent disconnect events explicitly
- Attachments should include MIME type and category
