API Reference - Chat Messages

Link: https://support.brilliantdirectories.com/support/solutions/articles/12000108082

← Back to API Reference | Getting Started

Chat Messages

Chat Messages are individual messages within a live chat conversation. Each message belongs to a chat thread (identified by thread_token) and is authored by a specific participant (identified by message_owner). The message content supports HTML. Chat Messages are created when users interact with the site's live chat widget.

Model name in URL: chat_message_items — DB table: chat_message_items

The Chat Message Object

FieldTypeDescription
message_idintegerUnique message ID (primary key, read-only)
message_tokenstringUnique token identifying this message
thread_tokenstringToken of the chat thread this message belongs to
message_statusintegerMessage status: 0 unread, 1 read
message_ownerstringToken or identifier of the message author
message_contenttextHTML content of the message
created_atstringDate and time the message was sent (format: YYYYMMDDHHmmss)

List Chat Messages

GET /api/v2/chat_message_items/get

Example Request

Copy
curl -X GET "https://www.yourdomain.com/api/v2/chat_message_items/get?limit=25" \
  -H "X-Api-Key: your-api-key-here"

Example Response

Copy
{
  "status": "success",
  "message": [
    {
      "message_id": "1",
      "message_token": "c14c3df7dcf7dc2aced6a2d4a09bab9a",
      "thread_token": "395878c8a5f3ae1802c359ec7ac85619",
      "message_status": "0",
      "message_owner": "0986d338d31285f7578138137f8a7c87",
      "message_content": "

Hello, how can I help you?

", "created_at": "20240301120000" } ], "total": "9", "current_page": 1, "total_pages": 1 }

Retrieve a Chat Message

GET /api/v2/chat_message_items/get/{message_id}

Example Request

Copy
curl -X GET "https://www.yourdomain.com/api/v2/chat_message_items/get/1" \
  -H "X-Api-Key: your-api-key-here"

Example Response

Copy
{
  "status": "success",
  "message": [
    {
      "message_id": "1",
      "message_token": "c14c3df7dcf7dc2aced6a2d4a09bab9a",
      "thread_token": "395878c8a5f3ae1802c359ec7ac85619",
      "message_status": "0",
      "message_owner": "0986d338d31285f7578138137f8a7c87",
      "message_content": "

Hello, how can I help you?

", "created_at": "20240301120000" } ], "total": "9", "current_page": 1, "total_pages": 1 }

Create a Chat Message

POST /api/v2/chat_message_items/create

Example Request

Copy
curl -X POST "https://www.yourdomain.com/api/v2/chat_message_items/create" \
  -H "X-Api-Key: your-api-key-here" \
  -d "message_token=c14c3df7dcf7dc2aced6a2d4a09bab9a" \
  -d "thread_token=395878c8a5f3ae1802c359ec7ac85619" \
  -d "message_status=0" \
  -d "message_owner=0986d338d31285f7578138137f8a7c87" \
  -d "message_content=%3Cp%3EHello%2C+how+can+I+help+you%3F%3C%2Fp%3E" \
  -d "created_at=20240301120000"

Example Response

Copy
{
  "status": "success",
  "message": {
    "message_id": "10",
    "message_token": "c14c3df7dcf7dc2aced6a2d4a09bab9a",
    "thread_token": "395878c8a5f3ae1802c359ec7ac85619",
    "message_status": "0",
    "message_owner": "0986d338d31285f7578138137f8a7c87",
    "message_content": "Hello, how can I help you?",
    "created_at": "20240301120000"
  }
}

Update a Chat Message

PUT /api/v2/chat_message_items/update

Example Request

Copy
curl -X PUT "https://www.yourdomain.com/api/v2/chat_message_items/update" \
  -H "X-Api-Key: your-api-key-here" \
  -d "message_id=10" \
  -d "message_status=1"

Example Response

Copy
{
  "status": "success",
  "message": {
    "message_id": "10",
    "message_token": "c14c3df7dcf7dc2aced6a2d4a09bab9a",
    "thread_token": "395878c8a5f3ae1802c359ec7ac85619",
    "message_status": "1",
    "message_owner": "0986d338d31285f7578138137f8a7c87",
    "message_content": "Hello, how can I help you?",
    "created_at": "20240301120000"
  }
}

Delete a Chat Message

DELETE /api/v2/chat_message_items/delete

Example Request

Copy
curl -X DELETE "https://www.yourdomain.com/api/v2/chat_message_items/delete" \
  -H "X-Api-Key: your-api-key-here" \
  -d "message_id=10"

Example Response

Copy
{
  "status": "success",
  "message": "chat_message_items record was deleted"
}