Jump to: navigation, search
(ChatStateChangeMessage)
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
=CometD notifications=
 
=CometD notifications=
__TOC__
+
__NOTOC__
 
You can subscribe to the '''/v2/me/chats''' topic to receive [[AsynchronousEvents|CometD]] notifications for the Chat API. This topic provides messages related to chats, including changes to chat state, updates to chat participant information, updates to chat data, and updates to chat transcript. It supports the following message types:  
 
You can subscribe to the '''/v2/me/chats''' topic to receive [[AsynchronousEvents|CometD]] notifications for the Chat API. This topic provides messages related to chats, including changes to chat state, updates to chat participant information, updates to chat data, and updates to chat transcript. It supports the following message types:  
 
*[[ChatMessageType#ChatStateChangeMessage|ChatStateChangeMessage]]
 
*[[ChatMessageType#ChatStateChangeMessage|ChatStateChangeMessage]]
Line 11: Line 11:
 
|-
 
|-
 
| data
 
| data
| The data element is present in all [[CometDNotifications|CometD]] notifications and is the root JSON element. The <tt>data.messageType</tt> property can always be used to identify the message and determine what other properties should be present.
+
| The data element is present in all CometD notifications and is the root JSON element. You can use data.messageType to identify the message and determine what other properties should be present.
 
|-
 
|-
 
| data.messageType
 
| data.messageType
| This property identifies the message type and will have a value of <tt>ChatStateChangeMessage</tt>.
+
| This property identifies the message type, in this case ChatStateChangeMessage.
 
|-
 
|-
 
| data.notificationType
 
| data.notificationType
| This property further identifies the type of notification. See the table below for more details.
+
| This property further identifies the type of notification and can have one of the following values:
 +
*StatusChange &mdash; The status of the chat has changed.
 +
*ParticipantsUpdated &mdash; The chat participants have changed.
 +
*PropertiesUpdated &mdash; The chat data has changed.
 +
*Error &mdash; This is sent when an operation on the chat resource fails.
 
|-
 
|-
 
| data.chat
 
| data.chat
| A chat resource with the updated state and capabilities.
+
| A [[ChatResources|chat resource]] with the updated state and capabilities.
 
|-
 
|-
| channel
+
| data.referenceId
| The topic the message was published to.
+
| The reference identifier is used to link the notification to the original request that created it.
|}
 
  
'''notificationType'''
 
The notificationType property can have one of the following values:
 
{|
 
! Type
 
! Description
 
|-
 
| StatusChange
 
| The status of the chat has changed.
 
|-
 
| ParticipantsUpdated
 
| The chat participants have changed.
 
|-
 
| PropertiesUpdated
 
| The chat data has changed.
 
|-
 
| Error
 
| This is sent when an operation on chat resource did not succeed.
 
 
|}
 
|}
  
Line 97: Line 83:
 
! Description
 
! Description
 
|-
 
|-
|  
+
| data
|  
+
| The data element is present in all CometD notifications and is the root JSON element. You can use data.messageType to identify the message and determine what other properties should be present.
 +
|-
 +
| data.messageType
 +
| This property identifies the message type, in this case MessageLogUpdated.
 
|-
 
|-
|  
+
| data.notificationType
|  
+
| This property further identifies the type of notification and has a value of NewMessages.
 
|-
 
|-
|  
+
| data.messages
|  
+
| A list of messages/notifications that were exchanged in chat. The value of data.messages.messageType is the value originally passed as the <tt>messageType</tt> on the [[Documentation:HTCC:API:ChatSend|SendMessage]] operation. This value is only included if you set the [[Documentation:HTCC:Dep:HTCCConfigurationOptionsReference#includeMessageType|includeMessageType]] option to <tt>true</tt>.
 
|-
 
|-
|  
+
| data.chatUri
|  
+
| The location of the chat resource.
 
|}
 
|}
  
 
====Example====
 
====Example====
 
<source lang="text">
 
<source lang="text">
 +
 +
  "data":{ 
 +
      "notificationType":"NewMessages",
 +
      "messageType":"MessageLogUpdated",
 +
      "messages":[ 
 +
        { 
 +
            "index":3,
 +
            "from":{ 
 +
              "nickname":"TestName",
 +
              "type":"Agent",
 +
              "participantId":"007352CE72D50290"
 +
            },
 +
            "messageType": "Greeting",
 +
            "text":"How may I help you?",
 +
            "visibility":"All",
 +
            "timestamp":"2014-01-09 11:58:12.035+0200",
 +
            "type":"Text",
 +
            "timestampSeconds":1389261492035           
 +
        },
 +
        { 
 +
            "index":4,
 +
            "from":{ 
 +
              "nickname":"TestName",
 +
              "type":"Agent",
 +
              "participantId":"007352CE72D50290"
 +
            },
 +
            "text":"Are you still there?",
 +
            "visibility":"All",
 +
            "timestamp":"2014-01-09 11:58:12.047+0200",
 +
            "type":"Text",
 +
            "timestampSeconds":1389261492047           
 +
        }
 +
      ],
 +
      "chatUri":"http://localhost:8080/api/v2/chats/0000Wa9CAM6W00FN"
 +
  }
 +
}
 
</source>
 
</source>
  
  
 
[[Category:V:HTCC:8.5.2DRAFT]]
 
[[Category:V:HTCC:8.5.2DRAFT]]

Latest revision as of 12:35, September 21, 2021

CometD notifications

You can subscribe to the /v2/me/chats topic to receive CometD notifications for the Chat API. This topic provides messages related to chats, including changes to chat state, updates to chat participant information, updates to chat data, and updates to chat transcript. It supports the following message types:

ChatStateChangeMessage

Property Description
data The data element is present in all CometD notifications and is the root JSON element. You can use data.messageType to identify the message and determine what other properties should be present.
data.messageType This property identifies the message type, in this case ChatStateChangeMessage.
data.notificationType This property further identifies the type of notification and can have one of the following values:
  • StatusChange — The status of the chat has changed.
  • ParticipantsUpdated — The chat participants have changed.
  • PropertiesUpdated — The chat data has changed.
  • Error — This is sent when an operation on the chat resource fails.
data.chat A chat resource with the updated state and capabilities.
data.referenceId The reference identifier is used to link the notification to the original request that created it.

Example

{  
   "data":{  
      "notificationType":"PropertiesUpdated",
      "messageType":"ChatStateChangeMessage",
      "chat":{  
         "userData":{  
            "key1":"value1",
            "key2":"value2"
         },
         "state":"Chatting",
         "capabilities":[  
            "Transfer",
            "Leave",
            "Invite",
            "Consult",
            "SetInFocus",
            "SetDisposition",
            "AttachUserData",
            "DeleteUserData",
            "UpdateUserData",
            "Complete",
            "SendMessage",
            "SendStartTypingNotification",
            "SendStopTypingNotification"
         ],
         "uri":"http://localhost:8080/api/v2/chats/0000Wa9CAM6W00J",
         "participants":[  
            {  
               "nickname":"test_consult_clientL",
               "type":"Customer",
               "participantId":"007352CE982D031B"
            },
            {  
               "nickname":"TestName",
               "type":"Agent",
               "participantId":"007352CE984F0321"
            }
         ],
         "id":"0000Wa9CAM6W00J"
      },
      "referenceId":83
   }
}

MessageLogUpdated

Property Description
data The data element is present in all CometD notifications and is the root JSON element. You can use data.messageType to identify the message and determine what other properties should be present.
data.messageType This property identifies the message type, in this case MessageLogUpdated.
data.notificationType This property further identifies the type of notification and has a value of NewMessages.
data.messages A list of messages/notifications that were exchanged in chat. The value of data.messages.messageType is the value originally passed as the messageType on the SendMessage operation. This value is only included if you set the includeMessageType option to true.
data.chatUri The location of the chat resource.

Example

{  
   "data":{  
      "notificationType":"NewMessages",
      "messageType":"MessageLogUpdated",
      "messages":[  
         {  
            "index":3,
            "from":{  
               "nickname":"TestName",
               "type":"Agent",
               "participantId":"007352CE72D50290"
            },
            "messageType": "Greeting",
            "text":"How may I help you?",
            "visibility":"All",
            "timestamp":"2014-01-09 11:58:12.035+0200",
            "type":"Text",
            "timestampSeconds":1389261492035            
         },
         {  
            "index":4,
            "from":{  
               "nickname":"TestName",
               "type":"Agent",
               "participantId":"007352CE72D50290"
            },
            "text":"Are you still there?",
            "visibility":"All",
            "timestamp":"2014-01-09 11:58:12.047+0200",
            "type":"Text",
            "timestampSeconds":1389261492047            
         }
      ],
      "chatUri":"http://localhost:8080/api/v2/chats/0000Wa9CAM6W00FN"
   }
}
This page was last edited on September 21, 2021, at 12:35.
Comments or questions about this documentation? Contact us for support!