When a message is posted, either by the agent or user, the onMessageCreate event is invoked and the registered callback method is executed.
Subscribe to the onMessageCreate event and register the callback by using the following sample manifest.json content.
"events": {
"onMessageCreate": {
"handler": "onMessageCreateCallback"
}
}Define the corresponding callback by using the following sample server.js content:
exports = {
onMessageCreateCallback: function(payload) {
console.log("Logging arguments from onMessageCreate event: " + JSON.stringify(payload));
}
}Attributes of the data object
- actorobject
Details of the entity that posted the message.
- avatarobject
Image associated with the actor.
- urlstring
Link from which the image is fetched.
- emailstring
Email of the actor.
- first_namestring
First name of the actor.
- idstring
Identifier associated with the actor, either the user_id or agent_id.
- last_namestring
Last name of the actor.
- phonestring
Phone number of the actor.
- typestring
Descriptive identifier of the entity who posted the message.
Possible values (enum): agent, user
- associationsobject
Associated objects related to the message object.
- channelobject
Details of the topic under which the message is posted.
- enabledboolean
Specifies whether all users can post messages under the topic.
Possible values: true, false
- iconimage object
Pictorial representation of the topic.
- urlstring
Link from which the image is fetched.
- idstring
Identifier of the topic under which the message is posted.
- namestring
Meaningful description of the topic. For example: Support, Billing.
- publicboolean
Specifies whether all users can post messages under the topic.
Possible values: true, false
- tagsarray of strings
Labels with which topics are tagged for different users.
- updated_timestring
Timestamp of when the topic is last updated, specified in the UTC format.
- welcome_messageobject
Message that sets context about the purpose of the channel.
- groupobject
Details of the group to which the conversation is assigned for resolution.
- descriptionstring
Meaningful definition that specifies the purpose of the group.
- idstring
Identifier of the group from which an agent has replied to the user message.
- namestring
Descriptive identifier of the group.
- routing_typestring
Specifies whether group members can accept auto-assigned conversations.
Possible values: Intelliassign, Disabled
- usersobject
Details of the user who posted the message or to whom the message is posted.
- avatarimage object
Image associated with the user.
- urlstring
Link from which the image is fetched.
- created_timestring
Timestamp of when the user information is created, specified in the UTC format.
- emailstring
Email address of the user.
- first_namestring
Business name of the user.
- idstring
Identifier of the user. This is an auto-generated value.
- last_namestring
Last name of the user.
- phonestring
Phone number of the user.
- propertiesarray of property objects
Custom properties for additional user information. This attribute contains custom property names and the corresponding values, as a valid JSON object of key (custom property name)-value (custom property’s value) pairs.
- namestring
Name of the custom property.
- valuestring
Value of the custom property.
- reference_idstring
Identifier of external references, such as email or phone number, input by the user.
- messageobject
Details of the message that triggered the onMessageCreate event.
- app_idstring
Alias of the Freshworks account ID.
- assigned_group_idstring
Identifier of the group to which the conversation is assigned for resolution.
- assigned_timestring
Timestamp of when the conversation is assigned to an agent or a group, specified in the UTC format.
- channel_idstring
Identifier of the topic under which the message that triggered onMessageCreate is posted.
- conversation_idstring
Identifier of the conversation object. This is an auto-generated value.
- created_timestring
Timestamp of when the conversation is created, specified in the UTC format.
- messagesarray of messages objects
Messages that constitute the conversation.
- actor_idstring
Identifier of the entity who posted the message that triggered the onMessageCreate event.
- actor_typestring
Descriptive identifier of the entity who posted the message. Possible values: user, agent
- app_idstring
Alias of the Freshworks account ID.
- channel_idstring
Identifier of the topic under which the message is posted. This is an auto-generated value.
- conversation_idstring
Identifier of the conversation object. This is an auto-generated value.
- created_timestring
Timestamp of when the message is created, specified in the UTC format.
- message_partsarray of message_part objects
Message stored as different parts - plain text, images, url buttons, a combination of text and image, or a combination of text, image, and url buttons. Only one attribute should be present in the message_part object.
- collectionarray of objects
Combinations of text, image, url_button, and quick_reply_button.
- imageobject
Image part of the message in the conversation.
- urlstring
Location of the image file.
- textobject
Text part of the message in the conversation.
- contentstring
Actual content of the text message.
- quick_reply_buttonobject
Key value pairs containing the custom_reply_text and label.
- Custom_reply_textstring
Custom text that is used as a reply text.
- labelstring
Label on the button that is used to give a quick reply.
- url_buttonobject
Links in the message.
- urlstring
The hyperlink that is accessed by clicking the corresponding label.
- labelstring
Text (in the message) that is used as the connector to the hyperlink.
- targetstring
Specifies where the link is opened. If the value is _self, the link is opened within the conversation widget. If the value is _blank, the link is opened in a new tab.
Possible values (enum): _self, _blank
Default value: _blank
- message_typestring
Descriptive identifier specifying the type of message.
Possible values: normal, private
- reopened_timestring
Timestamp of when the conversation is reopened, specified in the UTC format.
- response_due_typestring
Priority assigned to the conversation.
Possible values: First Response Due, No Response Due, Response Due
- statusstring
Status of the conversation.
Possible values: new, resolved, assigned.
- user_idstring
Identifier of the user who posted the message or to whom the message is posted. This is an auto-generated value.