Chat Widget

Get Chat Widget Script

get

Returns the JavaScript code needed to embed the chat widget on a website

Responses
200
JavaScript code for chat widget
application/javascript
Responsestring

JavaScript code

get
GET /v1/scripts/chat-widget.js HTTP/1.1
Host: api.dmchamp.com
Accept: */*
200

JavaScript code for chat widget

text

Get Chat Widget Configuration

get

Returns the configuration for the chat widget

Query parameters
configIdstringRequired

ID of the chat widget configuration

Responses
200
Chat widget configuration
application/json
get
GET /v1/chat-widget-config HTTP/1.1
Host: api.dmchamp.com
Accept: */*
{
  "success": true,
  "data": {}
}

Get Chat Widget

get

Returns the HTML for the chat widget with the specified configuration

Path parameters
configIdstringRequired

ID of the chat widget configuration

Responses
200
HTML content for the chat widget
text/html
Responsestring

HTML content

get
GET /v1/chat-widget/{configId} HTTP/1.1
Host: api.dmchamp.com
Accept: */*
text

Get Chat Widget with From ID

get

Returns the HTML for the chat widget with the specified configuration and from ID

Path parameters
configIdstringRequired

ID of the chat widget configuration

fromIdstringRequired

ID of the source (for tracking purposes)

Responses
200
HTML content for the chat widget
text/html
Responsestring

HTML content

get
GET /v1/chat-widget/{configId}/{fromId} HTTP/1.1
Host: api.dmchamp.com
Accept: */*
text

Handle Incoming Chat Widget Message

post

Processes an incoming message from the chat widget and publishes it to a PubSub topic

Query parameters
userIdstringRequired

ID of the user/owner to whom the chat widget belongs

Body
messageTypestringRequired

Type of message (e.g., text, reaction)

Default: text
Responses
200
Message processed successfully
application/json
post
POST /v1/incoming-chat-widget-message HTTP/1.1
Host: api.dmchamp.com
Content-Type: application/json
Accept: */*
Content-Length: 152

{
  "customData": {
    "messageSid": "msg123",
    "fromId": "visitor123",
    "toId": "widget456",
    "body": "Hello from chat widget",
    "status": "received"
  },
  "messageType": "text"
}
{
  "success": true,
  "messageId": "1234567890"
}

Get Chat Widget Messages

get

Retrieves messages for a specific chat widget conversation

Query parameters
fromIdstringRequired

ID of the user/owner of the contact

toIdstringRequired

ID of the chat widget that the contact is using

afterstring ยท int64Optional

Optional timestamp (in milliseconds) to fetch only messages after this time

Responses
200
List of messages with bot typing status
application/json
get
GET /v1/chat-widget-messages HTTP/1.1
Host: api.dmchamp.com
Accept: */*
{
  "messages": [
    {
      "messageSid": "msg123abc",
      "body": "Hello there, how can I help you?",
      "mediaUrl": null,
      "mediaContentType": null,
      "timestamp": "2023-05-15T14:30:45.123Z",
      "type": "text",
      "direction": "outbound",
      "status": "delivered"
    },
    {
      "messageSid": "msg456def",
      "body": "I have a question about your services",
      "mediaUrl": null,
      "mediaContentType": null,
      "timestamp": "2023-05-15T14:30:15.456Z",
      "type": "text",
      "direction": "inbound",
      "status": "delivered"
    }
  ],
  "isBotTyping": false
}

Mark Chat Widget Messages as Read

post

Updates the read status of all unread messages for a specific chat widget conversation

Body
fromIdstringRequired

ID of the user/owner of the contact

toIdstringRequired

ID of the chat widget that the contact is using

Responses
200
Messages marked as read successfully
application/json
post
POST /v1/update-message-read-status HTTP/1.1
Host: api.dmchamp.com
Content-Type: application/json
Accept: */*
Content-Length: 39

{
  "fromId": "user123",
  "toId": "widget456"
}
{
  "success": true
}

Was this helpful?