Product Events

Events that occur in the Freshchat product, such as initiating a conversation or resolving a conversation, are termed as product events. You can enable product events to trigger apps. To do this, configure event listeners in the manifest.json file. When a product event occurs, the corresponding event listener invokes a callback method defined in server.js. The app logic in the callback method runs with the help of the event-specific payload passed to the callback method.

Note: The serverless component of the app is executed in sandbox mode where some methods, such as setTimeout and setInterval, cannot be used.

Configure Events

To register a product event and the corresponding callback:

  1. From your app’s root directory, navigate to the manifest.json file.
  2. Include the events attribute, specifying the product event and the corresponding callback methods as follows:
    Copied Copy
    1
    2
    3
    4
    5
    "events": { "<eventName>": { "handler": "<eventCallbackMethod>" } }

    Note: Include only one callback method for an event. Multiple events can access the same callback method.

  3. Navigate to the server.js file.
  4. In the exports block, enter the callback function definition as follows:
    Copied Copy
    1
    2
    3
    4
    5
    6
    7
    exports = { // args is a JSON block containing the payload information // args["iparam"] will contain the installation parameter values //eventCallbackMethod is the call-back function name specified in manifest.json eventCallbackMethod: function(args) { console.log("Logging arguments from the event: " + JSON.stringify(payload)); }};

Payload Attributes

When a product event occurs, an event-specific payload is passed to the callback method.

Copied Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
{ "account_id" : "value", "event" : "value", "region" : "value", "timestamp" : "value", "data" : { //Contains the list of objects related to the event. }, "iparams" : { "Param1" : "value", "Param2" : "value" } }
EXPAND ↓

The payload is a JSON object with the following attributes.

Attribute Type Description
account_id string Identifier of the Freshchat account, auto-generated when the account is configured for a business.
event string Name of the product event.
region string Region where the account is deployed.
Possible values: US, EU, EUC, AUS, and IND
timestamp number Timestamp of when the product event occurs, specified in the epoch format.
iparams object Installation parameters specified as a JSON object of <parameter name>: <parameter value> pairs.
data object Event-specific data, specified as a JSON object of key:value pairs.
onConversationCreate

When a conversation is initiated by a user, the onConversationCreate event is invoked and the registered callback method is executed.

Register the onConversationCreate event by using the following sample manifest.json content.

Copied Copy
1
2
3
4
5
"events": { "onConversationCreate": { "handler": "onConversationCreateCallback" } }

Define the corresponding callback by using the following sample server.js content:

Copied Copy
1
2
3
4
5
exports = { onConversationCreateCallback: function(payload) { console.log("Logging arguments from onConversationCreate event: " + JSON.stringify(payload)); } }
Sample Payload
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{ "data": { "conversation": { "user_id": "98c76ba0-6b38-499b-9c37-e104774276b8", "reopened_time": null, "assigned_time": null, "created_time": "2019-07-29T14:51:56.933Z", "response_due_type": "FIRST_RESPONSE_DUE", "conversation_id": "8c65b83e-5be0-45f4-9645-9ddbbe015f4d", "app_id": "032c91b6-4b46-4f5b-adcb-102c72cd4efa", "messages": [ { "message_parts": [ { "text": { "content": "Hi" } } ], "app_id": "032c91b6-4b46-4f5b-adcb-102c72cd4efa", "actor_id": "98c76ba0-6b38-499b-9c37-e104774276b8", "id": "59abdc73-ce82-4a33-be10-93e61edc416a", "channel_id": "167e73ff-9dd5-4e2d-8c50-74161b38a6fe", "conversation_id": "8c65b83e-5be0-45f4-9645-9ddbbe015f4d", "message_type": "normal", "actor_type": "user", "created_time": "2019-07-29T14:51:56.933Z" } ], "status": "new", "channel_id": "167e73ff-9dd5-4e2d-8c50-74161b38a6fe", "assigned_group_id": "40753ac3-1f66-40d9-b903-23db0a9a70b0" }, "associations": { "group": { "id": "40753ac3-1f66-40d9-b903-23db0a9a70b0", "name": "Support", "description": "L1 support group", "routing_type": "DISABLED" }, "channel": { "id": "167e73ff-9dd5-4e2d-8c50-74161b38a6fe", "icon": {}, "updated_time": "2019-05-20T12:21:29.718Z", "enabled": true, "public": true, "name": "Inbox", "tags": [], "welcome_message": { "message_parts": [ { "text": { "content": "Hello there! Need help? Reach out to us right here, and we'll get back to you as soon as we can!" } } ], "message_type": "normal" } }, "user": { "properties": [ { "name": "siteId", "value": "Orders" } ], "created_time": "2019-07-29T20:21:42.063Z", "id": "98c76ba0-6b38-499b-9c37-e104774276b8", "first_name": "John", "last_name": "Doe", "email": "john.doe@gmail.com", "phone": "9876543212", "reference_id": "john.doe.198", "avatar": { "url": "https://s3.amazonaws.com/fresh-chat-names/img/john_doe.png" } } }, "actor": { "type": "user", "id": "98c76ba0-6b38-499b-9c37-e104774276b8", "first_name": "John", "last_name": "Doe", "email": "john.doe@gmail.com", "phone": "9876543212", "avatar": { "url": "https://s3.amazonaws.com/fresh-chat-names/img/john_doe.png" } } }, "region": "US", "account_id": "227655214724132", "domain": "web.freshchat.com", "event": "onConversationCreate", "timestamp": 1564392319214, "version": "1.0.0" }
EXPAND ↓

Attributes of the data object
ATTRIBUTE TYPE DESCRIPTION
conversation conversation object Details of the conversation object created when the onConversationCreate event is triggered.
associations object Associated objects related to the conversation object.
actor actor object Details of the entity that triggered the onConversationCreate event. For onConversationCreate, it is a user.

Attributes of the conversation object
ATTRIBUTE TYPE DESCRIPTION
user_id string Identifier of the user who initiates the conversation, auto-generated when onConversationCreate is triggered.
reopened_time string Timestamp of when a conversation is reopened, specified in the UTC format. This value is null for onConversationCreate.
assigned_time string Timestamp of when a conversation is assigned to an agent or a group, specified in the UTC format. This value is null for onConversationCreate.
created_time string Timestamp of when the conversation object is created, specified in the UTC format.
response_due_type string Priority assigned to a conversation. This value is First Response Due for onConversationCreate.
conversation_id string Identifier of the conversation object, auto-generated when the conversation is initiated.
app_id string Alias of the Freshchat account ID.
messages array of message objects Message that constitutes the conversation.
status string Status of a conversation. This value is new for onConversationCreate.
channel_id string Identifier of the topic under which the user posted the message that triggered onConversationCreate.
assigned_group_id string Identifier of the group to which a conversation is assigned for resolution. This value is null for onConversationCreate.

Attributes of the message object
ATTRIBUTE TYPE DESCRIPTION
message_parts array of message_part objects Different parts of the message - plain text, images, url buttons, a combination of text and image, or a combination of text, image, and url buttons.
app_id string Alias of the Freshchat account ID.
actor_id string Identifier of the entity who posted the message. Here, it is the user_id.
id string Identifier of the message object. This is an auto-generated value.
channel_id string Identifier of the topic under which the message is posted. This is an auto-generated value.
conversation_id string Identifier of the conversation object. This is an auto-generated value.
message_type string Descriptive identifier specifying whether the message is a private or normal message. This value is normal for onConversationCreate.
actor_type string Descriptive identifier of the entity that posted the message in the conversation. This value is user for onConversationCreate.
created_time string Timestamp of when the conversation is created, specified in the UTC format.

Attributes of the message_part object

Only one attribute should be present in the message_part object.

ATTRIBUTE TYPE DESCRIPTION
text text_part object Text part of a message in the conversation.
Attribute of the text_part object:
content (string): Actual content of the text message.
image image_part object Image part of the message in the conversation.
Attribute of the image_part object:
url (string): Location of the image file.
url_button url_button_part object Links in the message.
Attributes of the url_button_part object:
url (string): The hyperlink that is accessed by clicking the corresponding label.
label (string): Text (in the message) that is used as the connector to the hyperlink.
target (string): Location where the link is opened.
Possible values (enum): _self, _blank
Default value: _blank
collection array of message sub-part object Combination of text, image, and url_button.

Attributes of the channel object
ATTRIBUTE TYPE DESCRIPTION
id string Identifier of the topic under which the message that triggered onConversationCreate is posted.
icon image object Pictorial representation of the topic.
Attribute of the image object:
url (string): Link from which the image is fetched.
updated_time string Timestamp of when the topic is last updated, specified in the UTC format.
enabled boolean Specifies whether all users can post messages under the topic.
Possible values: true, false
public boolean Specifies whether all users can post messages under the topic.
Possible values: true, false
name string Meaningful description of the topic. For example: Support, Billing
tags array of strings Labels with which topics are tagged for different users.
welcome_message welcome_message object Message that sets context about the purpose of the topic.

Attributes of the user object
ATTRIBUTE TYPE DESCRIPTION
properties array 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.
Attributes of the property object:
name (string): Name of the custom property.
value (string): Value of the custom property.
created_time string Timestamp of when the user information is created, specified in the UTC format.
id string Identifier of the user, auto-generated when the conversation is initiated.
first_name string Business name of the user.
last_name string Last name of the user.
email string Email address of the user.
phone string Phone number of the user.
reference_id string Identifier of external references, such as email or phone number, input by the user.
avatar image object Image associated with the user.
Attribute of the image object:
url (string): Link from which the image is fetched.

Attributes of the actor object
ATTRIBUTE TYPE DESCRIPTION
type string Descriptive identifier of the entity who posted the message in the conversation. This value is user for onConversationCreate.
id string Identifier associated with the actor. Here, it is the user_id.
first_name string Business name of the actor.
last_name string Last name of the actor.
email string Email address of the actor.
phone string Phone number of the actor.
avatar image object Image associated with the actor.
Attribute of the image object:
url (string): Link from which the image is fetched.
onConversationUpdate

The onConversationUpdate event is triggered in the Freshchat system when,

  • A conversation is assigned to an agent or a group.
  • An existing conversation is reassigned to an agent or unassigned from a group.
  • A conversation is resolved or reopened.

Register the onConversationUpdate event by using the following sample manifest.json content.

Copied Copy
1
2
3
4
5
"events": { "onConversationUpdate": { "handler": "onConversationUpdateCallback" } }

Define the corresponding callback by using the following sample server.js content:

Copied Copy
1
2
3
4
5
exports = { onConversationUpdateCallback: function(payload) { console.log("Logging arguments from onConversationUpdate event: " + JSON.stringify(payload)); } }
Sample Payload
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
{ "region": "US", "account_id": "227655214724132", "domain": "web.freshchat.com", "event": "onConversationUpdate", "timestamp": 1564394238524, "version": "1.1.0", "data": { "conversation": { "conversation_id": "4ec945ec-6717-409d-9549-198d5d121bd1", "created_time": "2019-07-25T10:01:23.564Z", "reopened_time": "2019-07-29T14:51:56.933Z", "assigned_time": "2019-07-29T14:55:00.234Z", "user_id": "57fdd128-eb6d-44a8-9757-d7003966ad09", "app_id": "032c91b6-4b46-4f5b-adcb-102c72cd4efa", "messages": [{ "id": "f0cf8a2a-0772-4cce-be54-ebcb1bc68860", "created_time": "2019-07-29T15:27:17.972Z", "app_id": "032c91b6-4b46-4f5b-adcb-102c72cd4efa", "actor_id": "2823233e-7122-4f87-9d56-38aaaaeb676a", "channel_id": "d2f99658-ff98-44b8-b5c1-3a19dbfe2a2d", "conversation_id": "4ec945ec-6717-409d-9549-198d5d121bd1", "user_id": "126a5aa9-08a9-4aa5-adfc-98d6c322b3de", "interaction_id": "547990995047808-1651741135319", "actor_type": "user", "org_contact_id": null, "statistics": null, "is_agent_interim_first_response": false, "message_type": "system", "reply_parts": null, "message_source": null, "message_parts": [{ "reference": null, "quick_reply_button": null, "collection": null, "faq": null, "url_button": null, "image": null, "text": { "content": "Conversation was reopened by John Doe" }, "template_content": null, "callback": null, "help_text": null, "attachment_input": null, "video": null, "csat": null, "file": null, "text_input": null }], "in_reply_to": null, "status": null, "is_first_message": false, "error_message": null, "error_category": null, "org_actor_id": "249487083398969072", "meta_data": { "isResolved": true }, "error_code": null, "is_agent_first_response": false, "stepId": null }], "org_contact_id": null, "first_group_assigned_time": "2022-05-19T10:00:12.963Z", "source": "WEBCHAT", "assigned_org_agent_id": "249487083398969072", "first_agent_assigned_time": "2022-05-19T10:00:28.760Z", "statistics": { "first_agent_assignment_time_chrs": 1213293, "first_agent_assignment_time_bhrs": 1213293, "group_reassignment_time_bhrs": 0, "agent_reassignment_time_chrs": 0, "agent_reassignment_time_bhrs": 0, "resolution_time_bhrs": 14, "first_group_assignment_time_chrs": 1213278, "wait_time_chrs": 0, "first_response_time_bhrs": 0, "wait_time_bhrs": 0, "resolution_time_chrs": 14, "group_reassignment_time_chrs": 0, "first_group_assignment_time_bhrs": 1213278, "first_response_time_chrs": 0 }, "response_due_type": "NO_RESPONSE_DUE", "users": null, "agents": null, "group_assigned_time": "2022-05-19T10:00:25.302Z", "resolved_time": "2022-05-19T10:11:24.917Z", "assigned_group_id": "40753ac3-1f66-40d9-b903-23db0a9a70b0", "assigned_org_group_id": null, "label_category_id": null, "label_subcategory_id": null, "channel_id": "d2f99658-ff98-44b8-b5c1-3a19dbfe2a2d", "status": "new", "is_offline": false, "do_not_auto_resolve": false, "assigned_agent_id": "2823233e-7122-4f87-9d56-38aaaaeb676a" }, "associations": { "label_category": null, "channel": { "id": "d2f99658-ff98-44b8-b5c1-3a19dbfe2a2d", "updated_time": "2019-06-23T14:00:45.208Z", "assign_to_group": { "internal_fields": null, "org_group_id": null, "name": "New group ", "business_calendar": null, "description": "new", "group_uid": null, "agents": null, "id": "d2f99658-ff98-44b8-b5c1-3a19dbfe2a2d", "agent_uids": null, "is_deactivated": false, "chat_group_id": null, "automatic_agent_assignment": null, "account_alias": null, "created_at": null, "routing_type": "DISABLED", "updated_at": null }, "configured_bot_details": null, "name": "Inbox", "tags": [], "icon": { "url": null }, "welcome_message": { "actor_type": null, "created_time": null, "message_type": "normal", "reply_parts": null, "user_id": null, "interaction_id": null, "id": null, "message_source": null, "channel_id": null, "message_parts": [{ "reference": null, "quick_reply_button": null, "collection": null, "faq": null, "url_button": null, "image": null, "text": { "content": "Hello there! Need help? Reach out to us right here, and we will get back to you as soon as we can!" }, "template_content": null, "callback": null, "help_text": null, "attachment_input": null, "video": null, "csat": null, "file": null, "text_input": null }], "in_reply_to": null, "status": null, "actor_id": null, "error_message": null, "app_id": null, "stepId": null, "error_category": null, "org_actor_id": null, "conversation_id": null, "meta_data": null, "error_code": null }, "enabled": true, "public": true, "locale": "en", "channel_integration_details": null }, "agent": { "id": "2823233e-7122-4f87-9d56-38aaaaeb676a", "created_time": "2020-11-19T10:52:36.024Z", "first_name": "Jon", "last_name": "Snow", "email": "jon.snow@freshworks.com", "avatar": { "url": "https://s3.amazonaws.com/fresh-chat-names/img/jon_snow.png" }, "status": 0, "biography": null, "org_contact_id": null, "org_agent_id": null, "external_role_ids": null, "freshid_uuid": "249487083398969072", "agent_status": null, "scope": null, "timezone": null, "availability_status": null, "is_deleted": false, "skill_id": null, "login_status": false, "role_id": "ACCOUNT_ADMIN", "groups": null, "locale": "en-us", "role_name": "Account Admin", "max_active_conv": null, "is_deactivated": false, "freshid_group_ids": null, "app_id": null, "routing_type": null, "social_profiles": [], "license_type": "fulltime", "phone": null, "internal_fields": null, "internalId": null, "internalDBAppId": 0 }, "label_subcategory": null, "group": { "id": "40753ac3-1f66-40d9-b903-23db0a9a70b0", "created_at": null, "updated_at": null, "name": "Support", "description": "L1 support group", "org_group_id": null, "business_calendar": null, "group_uid": null, "agents": null, "agent_uids": null, "is_deactivated": false, "automatic_agent_assignment": null, "routing_type": "DISABLED",, "internal_fields": null, "chat_group_id": null, "account_alias": null }, "user": { "id": "57fdd128-eb6d-44a8-9757-d7003966ad09", "created_time": "2019-07-29T00:51:50.776Z", "updated_time": "2022-04-13T04:51:45.424Z", "first_name": "John", "last_name": "Doe", "email": "jon.doe@freshworks.com", "reference_id": "john.doe.198", "phone": "9876543212", "properties": [{ "name": "plan", "value": "Estate" }], "avatar": { "url": "https://s3.amazonaws.com/fresh-chat-names/img/john_doe.png" }, "org_contact_id": null, "restore_id": null, "login_status": false, "status": null, "social_profiles": null } }, "actor": { "id": "2823233e-7122-4f87-9d56-38aaaaeb676a", "type": "system", "sub_type": "user", "first_name": "Jon", "last_name": "Doe", "email": "jon.doe@freshworks.com", "phone": "9876543212", "avatar": { "url": "https://s3.amazonaws.com/fresh-chat-names/img/jon_doe.png" }, "org_contact_id": null, "sub_entity": null, "login_status": false, "org_actor_id": "249487083398969072", "social_profiles": null }, "changes": { "model_changes": { "assigned_agent_id": [ "2823233e-7122-4f87-9d56-38aaaaeb676a", null ], "assigned_group_id": [ "40753ac3-1f66-40d9-b903-23db0a9a70b0", null ], "status": [ "resolved", "new" ] }, "system_changes": null, "misc_changes": null } } }
EXPAND ↓

Attributes of the data object
ATTRIBUTE TYPE DESCRIPTION
conversation conversation object Information pertaining to the conversation updated in the Freshchat system, which triggered the onConversationUpdate event.
associations associations object All associated objects of the conversation object, which specify additional information pertaining to the conversation updated.
actor actor object Information pertaining to the system, bot, agent, or user who triggered the onConversationUpdate event.
changes changes object Changes that triggered the onConversationUpdate event, specified as a JSON object of the following format:
1
2
3
4
5
6
7
8
"changes": { "model_changes": { //For non-array attributes "<conversation.attribute that changed>": ["New value", "Old value"] }, "system_changes": {}, "misc_changes": {} }
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"changes": { "model_changes": { "assigned_agent_id": [ "2823233e-7122-4f87-9d56-38aaaaeb676a", null ], "assigned_group_id": ["40753ac3-1f66-40d9-b903-23db0a9a70b0", null ], "status": [ "resolved", "new" ] }, "system_changes": null, "misc_changes": null }
EXPAND ↓

Attributes of the changes object:
model_changes (object): List of all attributes whose values have changed, along with the modified and old values of the attributes.
system_changes (object): List of all system-level parameters whose values have changed, along with the modified and old values.
misc_changes (object): List of all miscellaneous database parameters whose values have changed, along with the modified and old values.


Attributes of the conversation object
ATTRIBUTE TYPE DESCRIPTION
conversation_id string Identifier of the conversation object, auto-generated when a conversation record is created in the Freshchat system.
created_time string Timestamp of when the conversation is created in the Freshchat system, specified in the UTC format.
reopened_time string Timestamp of when the conversation is reopened, specified in the UTC format.
Note: Agents and the Freshchat system can reopen resolved conversations. The system reopens the conversation if it receives an unsatisfactory CSAT score.
For onConversationCreate, this attribute value is null.
assigned_time string Timestamp of when the conversation is assigned to a group or an agent, specified in the UTC format.
user_id string Identifier of the user object, auto-generated when a user record is created in the Freshchat system.
The value of conversation.user_id identifies the user who initiated the conversation.
app_id string Auto-assigned organization-level identifier that helps integrate applications with Freshchat.
messages array of message objects Details of the messages that constitute the conversation.
org_contact_id string Organization-level identifier of the user who initiated the conversation.
first_group_assigned_time string Timestamp of when a group was first assigned to the conversation, specified in the UTC format.
source string Source through which a user initiates the conversation.
Possible values:
  • MOBILE
  • WEBCHAT
  • FACEBOOK_MESSENGER
  • WHATSAPP
  • FB_NATIVE
  • ABC
  • LINE
  • FRESHBOTS_WIDGET
  • GBM
  • SMS
    assigned_org_agent_id string Organization-level identifier of the agent to whom the conversation is assigned for resolution.
    first_agent_assigned_time string Timestamp of when an agent is first assigned to the conversation, specified in the UTC format.
    statistics statistics object Detailed information about the conversation.
    response_due_type string Specifies whether a response is due for a message in the conversation and if so, whether the response due is a first response.
    Possible values: FIRST_RESPONSE_DUE, NO_RESPONSE_DUE, RESPONSE_DUE
    users array of strings Details of the users associated with the conversation.
    agents array of strings Details of the agents associated with the conversation.
    For onConversationUpdate, the value of this attribute is null when the conversation is unassigned.
    group_assigned_time string Timestamp of when the conversation is assigned to a group, specified in the UTC format.
    resolved_time string Timestamp of when the conversation is resolved, specified in the UTC format.
    For onConversationUpdate, the value of this attribute is null.
    assigned_group_id string Identifier of the group to which the conversation is assigned for resolution.
    assigned_org_group_id string Organization-level identifier of the group to which a conversation is assigned for resolution.
    label_category_id string Conversation labels helps organize conversations into categories and sub-categories based on common customer support issues.
    label_category_id is the identifier of the label associated with the updated conversation.
    label_subcategory_id string Conversation labels helps organize conversations into categories and sub-categories based on common customer support issues.
    label_subcategory_id is the identifier of the sub-category label associated with the updated conversation.
    channel_id string Identifier of the topic under which the conversation is created, auto-generated when a topic is created in the Freshchat system.
    status string Status of the conversation.
    Possible values: new, resolved, assigned
    is_offline boolean Specifies whether the agent assigned to the conversation is available online.
    Possible values: true, false
    do_not_auto_resolve boolean Specifies whether the conversation can be automatically resolved after a specified time period.
    Possible values: true, false
    assigned_agent_id string Identifier of the agent assigned to the conversation, auto-generated when an agent’s information is configured in the Freshchat system.

    Attributes of the message object
    ATTRIBUTE TYPE DESCRIPTION
    id string Identifier of the message object, auto-generated when a new message is successfully sent in a conversation.
    created_time string Timestamp of when the message is creaed, specified in the UTC format.
    app_id string Auto-assigned organization-level identifier that helps integrate applications with Freshchat.
    actor_id string Identifier of the entity who sends the message to the conversation.
    If a user sends the message, the value of this attribute is the same as conversation.user_id. If an agent sends the message, the value of this attribute is the same as conversation.assigned_agent_id.
    channel_id string Identifier of the topic under which the message is created, auto-generated when a topic is created in the Freshchat system.
    conversation_id string Identifier of the conversation object, auto-generated when a conversation record is created in the Freshchat system.
    The value of message.conversation_id identifies the conversation which includes the message.
    user_id string Identifier of the user who sent the message to the conversation.
    interaction_id string Identifier of the interaction, auto-generated when a conversation is initiated by an user or an agent.
    An interaction is a conversation from the time it is initiated to the time the conversation is resolved.
    actor_type string A meaningful identifier of the entity who sends the message to the conversation.
    Possible values: user, agent
    org_contact_id string Organization-level identifier of the user who sent the message.
    If an agent or the system sends the message, this attribute value is null.
    statistics statistics object Detailed information about the message.
    is_agent_interim_first_response boolean Specifies whether the message is the first response from the agent engaged in a conversation with the user.
    Possible values: true, false
    message_type string Type of message.
    Possible values:
    normal: Normal message that the agent or user has sent.
    private: Private message that the agent adds to the conversation and is not visible to the user.
    system: System generated message.
    reply_parts array of message part objects Details of the reply message sent in response to a message in the conversation.
    A reply_part attribute can exist only if message_part is present.
    message_source string Source through which the message is initiated.
    Possible values: web, system, mobile, api, freshdesk, zendesk, smooch, facebook_native
    message_parts array of message part objects Different parts of a message posted to the conversation. For example, plain text, images, url buttons, and so on. The message can be a combination of these attributes.
    in_reply_to string Identifier of the message to which this message is a reply.
    status string Status of the message.
    is_first_message boolean Specifies whether the message initiated the conversation.
    Possible values: true, false
    org_actor_id string Organization-level identifier of the actor who triggered the onConversationUpdate event.
    meta_data object Details of the conversation to which the message belongs.
    Attributes of the object:
    isResolved (boolean): Specifies whether the conversation is resolved.
    Possible values: true, false
    is_agent_first_response boolean Specifies whether the message is the first response an agent is sending after the conversation is initiated.
    Possible values: true, false
    stepId
    For internal purposes only
    string -

    Attributes of the message part object
    ATTRIBUTE TYPE DESCRIPTION
    reference reference object Attributes of the reference object:
    reference_id (string): Identifier of the reference object, auto-generated when a reference is created in the Freshchat system.
    label (string):
    quick_reply_button quick reply object The response enabler an agent posts to the conversation can be a quick reply button. The quick_reply_button attribute contains the different components of the button.
    Attributes of the quick reply object:
    custom_reply_text (string): Custom text that is used as reply text.
    label (string): Label on the button that is used to give a quick reply.
    payload (string): Data that is passed to the Freshchat system when a user responds using the quick reply button.
    collection collection part object Helps compose a response enabler that is a combination of text, image, url button, and quick reply buttons.
    Attribute of the collection part object:
    sub_parts (array of message part objects): Different parts of a response enabler posted to a conversation.
    In a response object, the collection attribute contains the different segments of the response enabler posted to the conversation.
    faq FAQ object In a conversation, the response an agent posts to the conversation can be an FAQ created in the Freshchat system.
    Attributes of the FAQ object:
    categoryId (integer): Identifier of the category object, auto-generated when a new category of FAQs are created in the Freshchat system.
    articleId (integer): Identifier of the article created under a category in the Freshchat system.
    url_button url button part object Links in a message.
    Attributes of the url button part object:
    url (string): The actual hyperlink that is accessed by clicking the corresponding label.
    label (string): Text (in the message) that is used as the connector to the hyperlink.
    target (string): Location where the link is opened.
    Possible values:
    _self: Link is opened within the conversation widget.
    _blank: Link is opened in a new tab.
    By default, _blank is the value of url_button.target.
    image image object Image part of the message posted to a conversation.
    Attribute of the image object:
    url (string): Location of the image file.
    template_content template content object

    The response enabler an agent posts to the conversation can be a templated message such as a carousel or drop-down list. The template_content attribute helps compose such a message.
    In a response object, the template_content attribute contains different segments of the templated response enabler posted to the conversation.

    Attributes of the template content object:
    type (string): Identifier of the type of templated message.
    Possible values:

    • carousel: A scrollable list of carousel cards are displayed as response enablers. The template_content.sections values are used to populate the carousel cards.
    • carousel_card_default: A single carousel card is displayed as a response enabler. The template_content.sections values are used to populate the carousel card.
    • quick_reply_dropdown: A drop-down list is displayed as the response enabler. The template_content.sections values are used to populate the drop-down list.
    sections (array of sections objects): Segments of the carousel card or drop-down list.

    Attributes of the sections object:
    name (string): Title of the carousel card or drop-down list displayed in the conversation window.
    parts (array of message part objects): Segments of the carousel card or values for the drop-down list.
    callback callback object In a conversation, the reply message can be a carousel card which has the callback attribute.
    Attributes of the callback object:
    payload (string): Data that is passed to the Freshchat system when a user responds using the carousel card.
    label (string): Text that is displayed on the button.
    attachment_input object Details of the file attached with the message.
    Attributes of the object:
    inputType (string): Identifier of the type of attachment.
    Possible values: file, image, video
    video video object Details of the video file attached to a message in a conversation.
    Attributes of the video object:
    url (string): Location of the video file.
    content_type (string): Format of the attached video.
    csat csat object Details of the CSAT score provided by the user for a conversation.
    Attributes of the csat object:
    rating (integer): Numeric value of the CSAT rating.
    Possible values: 0 - 5
    issue_resolved (boolean): Specifies whether the user who provided the CSAT rating has confirmed that the issue associated with the conversation has been resolved.
    response_text (string): Comment that the user provided as part of the rating.
    file file object Details of the file attached to a message in a conversation.
    Attributes of the file object:
    name (string): Name of the attached file.
    url (string): Link to the location from where the attached file can be retrieved.
    file_size_in_bytes (integer): Size of the attached file.
    content_type (string): Format of the attached file.
    text_input object Details extracted from the text message sent to the conversation.
    Attributes of the object:
    inputType (string): Possible values: email, phone, number, text
    help_text string -

    Attributes of the statistics object
    ATTRIBUTE TYPE DESCRIPTION
    first_agent_assignment_time_chrs integer Number of hours within which an agent is assigned to the conversation in the Freshchat system, regardless of the business hours.
    first_agent_assignment_time_bhrs integer Number of hours within which an agent is assigned to the conversation in the Freshchat system, during business hours.
    group_reassignment_time_bhrs integer Number of hours taken to reassign a conversation to another group after the first assignment, during business hours.
    agent_reassignment_time_chrs integer Number of hours taken to reassign a conversation to another agent after the first assignment, regardless of the business hours.
    agent_reassignment_time_bhrs integer Number of businesshours taken to reassign a conversation to another agent after the first assignment, during business hours.
    resolution_time_bhrs integer Number of hours taken to resolve a conversation, during business hours.
    first_group_assignment_time_chrs integer Number of hours taken to assign the conversation to a group in the Freshchat system.
    wait_time_chrs integer Number of hours a user has to wait before receiving a response to the message, regardless of the business hours.
    first_response_time_bhrs integer Number of hours taken to respond to a conversation after an agent is assigned, during business hours.
    wait_time_bhrs integer Number of hours a user has to wait before receiving a response to the message, during business hours.
    resolution_time_chrs integer Number of hours taken to resolve a conversation, regardless of the business hours.
    group_reassignment_time_chrs integer Number of hours taken to reassign a conversation to another group after the first assignment, regardless of the business hours.
    first_group_assignment_time_bhrs integer Number of hours within which the conversation is assigned to a group in the Freshchat system, during business hours.
    first_response_time_chrs integer Number of hours taken to respond to a conversation after an agent is assigned, regardless of the business hours.

    Attributes of the associations object
    ATTRIBUTE TYPE DESCRIPTION
    label_category string Name of the conversation label created to categorize conversations.
    channel channel object Details of the topic under which the message is posted.
    agent agent object Details of the agent to whom the conversation is assigned for resolution.
    label_subcategory string Name of sub-category label associated with the conversation.
    group group object Details of the group to which the conversation is assigned for resolution.
    user user object Details of the user who initiated the conversation.

    Attributes of the channel object
    ATTRIBUTE TYPE DESCRIPTION
    id string Identifier of the channel object, auto-generated when a topic is created in the Freshchat system.
    updated_time string Timestamp of when the topic is last updated, specified in the UTC format.
    assign_to_group group object Details of the group associated with the topic. If a group is associated with a topic, whenever a message is received under the topic, it is automatically assigned to the associated group.
    configured_bot_details string Details of the chatbot associated with the topic.
    name string Name of the topic. For example, Sales, Support and so on.
    tags array of strings Labels used to sort the conversations received under a topic, specified as an array.
    icon image object Pictorial representation of the topic.
    Attribute of the image object:
    url (string): Location of the image file.
    welcome_message message object Message that sets context about the purpose of the topic.
    enabled boolean Specifies whether a channel is currently available. Channels can be created by a business but can be disabled until a further point in time when there is a necessity to open the channel.
    Possible values: true, false
    public boolean Specifies whether the channel is open to receive messages from all users.
    Possible values: true, false
    locale string Primary language associated with the topic.

    Attributes of the agent object
    ATTRIBUTE TYPE DESCRIPTION
    id string Identifier of the agent object, auto-generated when the agent’s information is configured in the Freshchat system.
    created_time string Timestamp of when the agent’s record is created in the Freshchat system, specified in the UTC format.
    first_name string Business name of the agent.
    last_name string Last name of the agent.
    email string Email address of the agent.
    avatar image object Image associated with the agent.
    Attribute of the image object:
    url (string): Link from which the image is fetched.
    status integer Status set by the agent.
    Possible values:
    0: Active on IntelliAssign
    1: Unavailable
    biography string Meaningful description about the agent.
    org_contact_id string Organization-level identifier of the user who initiated the conversation.
    org_agent_id string Organization-level identifier of the agent associated with the conversation.
    freshid_uuid string Universally unique identifier of the agent across Freshworks’ master record.
    agent_status object Custom status set by the agent.
    New custom statuses, such as Away, In a meeting, and so on, can be added if the custom activity state feature is enabled for a business account that uses Freshchat.
    Attributes of the object:
    id (integer): Identifier of custom status, auto-generated when a new status is added to the Freshchat system.
    name (string): Title of the status.
    scope integer Access privileges of the agent.
    Possible values:
    1: Can access all conversations.
    2: Can access only the conversations assigned to the groups to which the agent belongs.
    3: Can access only conversations assigned specifically to the agent.
    4: No access.
    timezone string Timezone to which the agent belongs, in the Area/Location format.
    availability_status string Status of the agent’s availability for conversation assignment.
    Possible values: AVAILABLE, UNAVAILABLE
    is_deleted boolean Specifies whether the agent's details are deleted from the Freshchat system.
    Possible values: true, false
    skill_id string Identifiers of the skill mapped to the agent.
    When a new skill or load is created in the Freshchat system, a skill_id value is auto-generated and assigned to the skill.
    login_status boolean Specifies whether the agent is logged into the Freshchat system.
    Possible values: true, false
    role_id string System-generated identifier of the role assigned to the agent, that specifies the level of access permissions the agent has in the Freshchat system.
    Possible values: ACCOUNT_ADMIN, ADMIN, SUPER_USER, AGENT
    groups array of integers Identifiers of the groups to which the agent belongs, specified as an array.
    locale string Language associated with the agent’s location, specified in the ISO-639 code.
    role_name string Meaningful identifier of the agent’s role that specifies the agent’s level of access in the Freshchat system.
    Possible values: Account admin, Admin, Super user, Agent
    max_active_conv integer Maximum number of active conversations that the agent can manage.
    is_deactivated boolean Specifies whether the agent is deactivated in the Freshchat system.
    Possible values: true, false
    freshid_group_ids array of strings Universally unique identifiers, across Freshworks’ master record, that identify the groups to which the agent belongs, specified as an array.
    app_id string Auto-assigned organization-level identifier that helps integrate applications with Freshchat.
    routing_type string Type of assignment rule associated with the agent.
    Possible values:
    OCR (string): The agent is auto-assigned tickets, chats and phone calls based on the Omni-route assignment rule.
    INTELLIASSIGN (string): The agent is auto-assigned conversations based on the round-robin approach or load based approach.
    DISABLED (string): Auto-assignment of conversation is disabled.
    For more information about the assignment rules, see IntelliAssign in Freshchat.
    social_profiles array of social_profile objects Social platforms in which the agent is available.
    Attributes of the social_profile object:
    type (string): Name of the social media platform.
    Possible values (enum): facebook, twitter, skype, linkedin
    id (string): User ID of the agent on the platform.
    license_type string Availability of the agent.
    Possible values: fulltime, occasional
    phone string Phone number of the agent.
    internal_fields
    For internal purposes only
    string -
    internalId
    For internal purposes only
    string -
    internalDBAppId
    For internal purposes only
    integer -

    Attributes of the group object
    ATTRIBUTE TYPE DESCRIPTION
    id string Identifier of the group object, auto-generated when a new group is configured in the Freshchat system.
    created_at string Timestamp of when the group is created in the Freshchat system, specified in the UTC format.
    updated_at string Timestamp of when the group details are last updated in the Freshchat system, specified in the UTC format.
    name string Descriptive identifier for the group.
    description string Meaningful definition that specifies the purpose of the group.
    org_group_id string Organization-level identifier of the group.
    business_calendar string Details of the business hours associated with the group.
    group_uid Organization-level identifier of the agent group.
    agents array of strings Identifier of the agents associated with the group, specified as an array.
    agent_uids array of strings Organization-level identifier of the agents associated with the group, specified as an array.
    is_deactivated boolean Specifies whether the group is deactivated from the Freshchat system.
    Possible values: true, false
    automatic_agent_assignment object Details of the assignment rules, based on which the conversation is auto-assigned to the agent.
    Attributes of the object:

    enabled (boolean): Specifies whether the auto-assignment is enabled.
    Possible values: true, false

    type (string): Type of assignment rule.
    settings (object)
    routing_type string Type of assignment rules, based on which the conversation is auto-assigned to the group.
    Possible values:
    OCR (string): The agent is auto-assigned tickets, chats and phone calls based on the Omni-route assignment rule.
    INTELLIASSIGN (string): The agent is auto-assigned conversations based on the round-robin approach or load based approach.
    DISABLED (string): Auto-assignment of conversation is disabled.
    For more information about the assignment rules, see IntelliAssign in Freshchat.
    internal_fields
    For internal purposes only
    string -
    chat_group_id string
    account_alias string

    Attributes of the user object
    ATTRIBUTE TYPE DESCRIPTION
    id string Identifier of the user object, auto-generated when a user record is created in the Freshchat system.
    created_time string Timestamp of when the user record is created in the Freshchat system, specified in the UTC format.
    updated_time string Timestamp of when the user details are last updated in the Freshchat system, specified in the UTC format.
    first_name string Business name of the user.
    last_name string Last name of the user.
    email string Email address of the user.
    phone string Phone number of the user.
    properties array 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.
    Attributes of the property object:
    name (string): Name of the custom property.
    value (string): Value of the custom property.
    avatar image object Image associated with the user.
    Attribute of the image object:
    url (string): Link from which the image is fetched.
    org_contact_id string Organization-level identifier of the user who initiated the conversation.
    restore_id string Unique identifier of the user, auto-generated when a conversation is initiated in the Freshchat system.
    When the logged-in user is using a new device or browser for initiating a conversation, restore_id identifies the user for restoring the past conversations.
    login_status boolean Specifies whether the user is logged into the Freshchat system.
    Possible values: true, false
    status string Status of the user.
    Possible values: active, deleting, deleted
    social_profiles array of objects Details of the social media profiles of the user who initiated the conversation, specified as an array.
    Attributes of the object:
    id (integer): User handle of the user on the social media platform.
    type (string): Name of the social media platform.
    Possible values: facebook, twitter, skype, linkedin
    reference_id string -

    Attributes of the actor object
    ATTRIBUTE TYPE DESCRIPTION
    id string Identifier of the actor who triggered the product event.
    If the actor is an agent, the id value is the agent’s id that is auto-generated when the agent’s information is configured in the Freshchat system.
    If the actor is a user, the id value is the user’s id that is auto-generated when the user record is created in the Freshchat system.
    If the actor is the Freshchat system or the bot, the id value is null.
    first_name string Business name of the actor.
    The value of this attribute is null when the actor.type is system or bot.
    last_name string Last name of the actor.
    The value of this attribute is null when the actor.type is system or bot.
    email string Email address of the actor.
    The value of this attribute is null when the actor.type is system or bot.
    phone string Phone number of the actor.
    The value of this attribute is null when the actor.type is system or bot.
    avatar image object Image associated with the actor.
    Attribute of the image object:
    url (string): Location of the image file.
    The value of this attribute is null when the actor.type is system or bot.
    type string Name of the entity that triggered the product event.
    Possible values: user, system, agent, bot
    sub_entity string Details of the routing type, such as assignment rules, Intelliassign, topic-group mapping, and so on, that causes the conversation to be assigned to a specific agent/group, when the actor.type is system.
    Possible values: intelliAssign, rule, api, dsat, and channel
    org_contact_id string Organization-level identifier of the user who initiated the conversation.
    The value of this attribute is null when the actor.type is system or bot.
    sub_type string Same as sub_entity.
    login_status boolean Specifies whether the entity who triggered the event is logged into the Freshchat system.
    Possible values: true, fasle
    org_actor_id string Organization-level identifier of the actor who triggered the onConversationUpdate event.
    social_profiles array of objects Details of the social media profiles of the user or agent who triggered the product event, specified as an array.
    Attributes of the object:
    id (integer): User handle of the user or agent on the social media platform.
    type (string): Name of the social media platform.
    Possible values: facebook, twitter, skype, linkedin
    onMessageCreate

    When a message is posted, either by the agent or user, the onMessageCreate event is invoked and the registered callback method is executed.

    Register the onMessageCreate event by using the following sample manifest.json content.

    Copied Copy
    1
    2
    3
    4
    5
    "events": { "onMessageCreate": { "handler": "onMessageCreateCallback" } }

    Define the corresponding callback by using the following sample server.js content:

    Copied Copy
    1
    2
    3
    4
    5
    exports = { onMessageCreateCallback: function(payload) { console.log("Logging arguments from onMessageCreate event: " + JSON.stringify(payload)); } }
    Sample Payload
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    { "data": { "message": { "user_id": "98c76ba0-6b38-499b-9c37-e104774276b8", "reopened_time": null, "assigned_time": null, "created_time": "2019-07-29T14:51:56.933Z", "response_due_type": "FIRST_RESPONSE_DUE", "conversation_id": "8c65b83e-5be0-45f4-9645-9ddbbe015f4d", "app_id": "032c91b6-4b46-4f5b-adcb-102c72cd4efa", "messages": [ { "message_parts": [ { "text": { "content": "Hey again" } } ], "app_id": "032c91b6-4b46-4f5b-adcb-102c72cd4efa", "actor_id": "98c76ba0-6b38-499b-9c37-e104774276b8", "id": "17456eb1-4969-44a0-8c12-05b8b9604e7a", "channel_id": "167e73ff-9dd5-4e2d-8c50-74161b38a6fe", "conversation_id": "8c65b83e-5be0-45f4-9645-9ddbbe015f4d", "message_type": "normal", "actor_type": "user", "created_time": "2019-07-29T15:15:54.120Z" } ], "status": "new", "channel_id": "167e73ff-9dd5-4e2d-8c50-74161b38a6fe", "assigned_group_id": "40753ac3-1f66-40d9-b903-23db0a9a70b0" }, "associations": { "group": { "id": "40753ac3-1f66-40d9-b903-23db0a9a70b0", "name": "Support", "description": "L1 support group", "routing_type": "DISABLED" }, "channel": { "id": "167e73ff-9dd5-4e2d-8c50-74161b38a6fe", "icon": {}, "updated_time": "2019-05-20T12:21:29.718Z", "enabled": true, "public": true, "name": "Inbox", "tags": [], "welcome_message": { "message_parts": [ { "text": { "content": "Hello there! Need help? Reach out to us right here, and we'll get back to you as soon as we can!" } } ], "message_type": "normal" } }, "user": { "properties": [ { "name": "siteId", "value": "Orders" } ], "created_time": "2019-07-29T20:21:42.063Z", "id": "98c76ba0-6b38-499b-9c37-e104774276b8", "first_name": "John", "last_name": "Doe", "email": "jon.doe@freshworks.com", "reference_id": "john.doe.198", "phone": "9876543212", "avatar": { "url": "https://s3.amazonaws.com/fresh-chat-names/img/john_doe.png" } } }, "actor": { "type": "user", "id": "98c76ba0-6b38-499b-9c37-e104774276b8", "first_name": "John", "last_name": "Doe", "email": "jon.doe@freshworks.com", "phone": "9876543212", "avatar": { "url": "https://s3.amazonaws.com/fresh-chat-names/img/john_doe.png" } } }, "region": "US", "account_id": "227655214724132", "domain": "web.freshchat.com", "event": "onMessageCreate", "timestamp": 1564393556026, "version": "1.0.0" }
    EXPAND ↓

    Attributes of the data object
    ATTRIBUTE TYPE DESCRIPTION
    message message object Details of the message that triggered the onMessageCreate event.
    associations associations object Associated objects related to the message object.
    actor actor object Details of the entity that posted the message.

    Attributes of the message object
    ATTRIBUTE TYPE DESCRIPTION
    user_id string Identifier of the user who posted the message or to whom the message is posted. This is an auto-generated value.
    reopened_time string Timestamp of when the conversation is reopened, specified in the UTC format.
    assigned_time string Timestamp of when the conversation is assigned to an agent or a group, specified in the UTC format.
    created_time string Timestamp of when the conversation is created, specified in the UTC format.
    response_due_type string Priority assigned to the conversation.
    Possible values: First Response Due, No Response Due, Response Due
    conversation_id string Identifier of the conversation object. This is an auto-generated value.
    app_id string Alias of the Freshchat account ID.
    messages array of messages objects Messages that constitute the conversation.
    status string Status of the conversation.
    Possible values: new, resolved, assigned.
    channel_id string Identifier of the topic under which the message that triggered onMessageCreate is posted.
    assigned_group_id string Identifier of the group to which the conversation is assigned for resolution.

    Attributes of the messages object
    ATTRIBUTE TYPE DESCRIPTION
    message_parts array 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.
    app_id string Alias of the Freshchat account ID.
    actor_id string Identifier of the entity who posted the message that triggered the onMessageCreate event.
    channel_id string Identifier of the topic under which the message is posted. This is an auto-generated value.
    conversation_id string Identifier of the conversation object. This is an auto-generated value.
    message_type string Descriptive identifier specifying the type of message.
    Possible values: normal, private
    actor_type string Descriptive identifier of the entity who posted the message.
    Possible values: user, agent
    created_time string Timestamp of when the message is created, specified in the UTC format.

    Attributes of the message_part object

    Only one attribute should be present in the message_part object.

    ATTRIBUTE TYPE DESCRIPTION
    text text_part object Text part of the message in the conversation.
    Attribute of the text_part object:
    content (string): Actual content of the text message.
    image image_part object Image part of the message in the conversation.
    Attribute of the image_part object:
    url (string): Location of the image file.
    url_button url_button_part object Links in the message.
    Attributes of the url_button_part object:
    url (string): The hyperlink that is accessed by clicking the corresponding label.
    label (string): Text (in the message) that is used as the connector to the hyperlink.
    target (string): 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
    quick_reply_button quick_reply_button_part object Key value pairs containing the custom_reply_text and label.
    Attributes of the quick_reply_button_part object:
    Custom_reply_text (string): Custom text that is used as a reply text.
    label (string): Label on the button that is used to give a quick reply.
    collection array of message sub-part objects Combinations of text, image, url_button, and quick_reply_button.

    Attributes of the associations object
    ATTRIBUTE TYPE DESCRIPTION
    group group object Details of the group to which the conversation is assigned for resolution.
    channel channel object Details of the topic under which the message is posted.
    user user object Details of the user who posted the message or to whom the message is posted.

    Attributes of the group object
    ATTRIBUTE TYPE DESCRIPTION
    id string Identifier of the group from which an agent has replied to the user message.
    name string Descriptive identifier of the group.
    description string Meaningful definition that specifies the purpose of the group.
    routing_type string Specifies whether group members can accept auto-assigned conversations.
    Possible values: Intelliassign, Disabled

    Attributes of the channel object
    ATTRIBUTE TYPE DESCRIPTION
    id string Identifier of the topic under which the message is posted.
    icon image object Pictorial representation of the topic.
    Attribute of the image object:
    url (string): Link from which the image is fetched.
    updated_time string Timestamp of when the topic is last updated, specified in the UTC format.
    enabled boolean Specifies whether all users can post messages under the topic.
    Possible values: true, false
    public boolean Specifies whether all users can post messages under the topic.
    Possible values: true, false
    name string Meaningful description of the topic. For example: Support, Billing
    tags array of strings Labels with which topics are tagged for different users.
    welcome_message welcome_message object Message that sets context about the purpose of the channel.

    Attributes of the user object
    ATTRIBUTE TYPE DESCRIPTION
    properties array 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.
    Attributes of the property object:
    name (string): Name of the custom property.
    value (string): Value of the custom property.
    created_time string Timestamp of when the user information is created, specified in the UTC format.
    id string Identifier of the user. This is an auto-generated value.
    first_name string Business name of the user.
    last_name string Last name of the user.
    email string Email address of the user.
    reference_id string Identifier of external references, such as email or phone number, input by the user.
    phone string Phone number of the user.
    avatar image object Image associated with the user.
    Attribute of the image object:
    url (string): Link from which the image is fetched.

    Attributes of the actor object
    ATTRIBUTE TYPE DESCRIPTION
    type string Descriptive identifier of the entity who posted the message.
    Possible values (enum): user, agent
    id string Identifier associated with the actor, either the user_id or agent_id.
    first_name string Business name of the actor.
    last_name string Last name of the actor.
    email string Email address of the actor.
    phone string Phone number of the actor.
    avatar image object Image associated with the actor.
    Attribute of the image object:
    url (string): Link from which the image is fetched.
    onUserCreate

    When a user initiates a conversation, the onUserCreate event is invoked and the registered callback method is executed.

    Register the onUserCreate event by using the following sample manifest.json content.

    Copied Copy
    1
    2
    3
    4
    5
    "events": { "onUserCreate": { "handler": "onUserCreateCallback" } }

    Define the corresponding callback by using the following sample server.js content:

    Copied Copy
    1
    2
    3
    4
    5
    exports = { onUserCreateCallback: function(payload) { console.log("Logging arguments from onUserCreate event: " + JSON.stringify(payload)); } }
    Sample Payload
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    { "data": { "user": { "id": "b3c2c92e-d650-4c40-bb7d-aeb3423cd4d2", "reference_id": "john.doe.198", "created_time": "2019-07-29T14:51:56.933Z", "first_name": "John", "last_name": "Doe", "email": "john.doe@gmail.com", "phone": "9876543212", "avatar": { "url": "https://s3.amazonaws.com/fresh-chat-names/img/john_doe.png" }, "properties": [ { "name": "plan", "value": "Estate" } ] }, "actor": {}, "associations": {} }, "region": "US", "account_id": "227655214724132", "domain": "web.freshchat.com", "event": "onUserCreate", "timestamp": 1571036504512, "version": "1.0.0" }
    EXPAND ↓

    Attributes of the user object
    ATTRIBUTE TYPE DESCRIPTION
    id string Identifier of the user. This value is auto-generated when the conversation is initiated.
    reference_id string Identifier of external references, such as email or phone number, input by the user.
    created_time string Timestamp of when the user information is created, specified in the UTC format.
    first_name string Business name of the user.
    last_name string Last name of the user.
    email string Email address of the user.
    phone string Phone number of the user.
    avatar image object Image associated with the user.
    Attribute of the image object:
    url (string): Link from which the image is fetched.
    properties array 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.
    Attributes of the property object:
    name (string): Name of the custom property.
    value (string): Value of the custom property.
    actor actor object Details of the user who posted the message.
    associations associations object Associated objects related to the message object. This value is null for the onUserCreate event.
    onUserUpdate

    When a user's information is updated, either by the user or agent, the onUserUpdate event is invoked and the registered callback method is executed.

    Register the onUserUpdate event by using the following sample manifest.json content.

    Copied Copy
    1
    2
    3
    4
    5
    "events": { "onUserUpdate": { "handler": "onUserUpdateCallback" } }

    Define the corresponding callback by using the following sample server.js content:

    Copied Copy
    1
    2
    3
    4
    5
    exports = { onUserUpdateCallback: function(payload) { console.log("Logging arguments from onUserUpdate event: " + JSON.stringify(payload)); } }
    Sample Payload
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    { "data": { "user": { "created_time": "2019-07-29T14:51:56.933Z", "id": "b3c2c92e-d650-4c40-bb7d-aeb3423cd4d2", "reference_id": "john.doe.198", "first_name": "John", "last_name": "Doe", "email": "john.doe@gmail.com", "phone": "9876543212", "avatar": { "url": "https://s3.amazonaws.com/fresh-chat-names/img/john_doe.png" }, "properties": [ { "name": "plan", "value": "Estate" } ] }, "actor": { "type": "agent", "id": "98c76ba0-6b38-499b-9c37-e104774276b8", "first_name": "Jon", "last_name": "Snow", "email": "jon.snow@freshworks.com", "avatar": { "url": "https://s3.amazonaws.com/fresh-chat-names/img/jon_snow.png" } }, "associations": {}, "changes": { "model_changes": { "first_name": [ "Dancing Wayfarer", "John" ] } } }, "region": "US", "account_id": "235086843748457", "domain": "web.freshchat.com", "event": "onUserUpdate", "timestamp": 1571040876177, "version": "1.0.0" }
    EXPAND ↓

    Attributes of the data object
    ATTRIBUTE TYPE DESCRIPTION
    user user object Details of the user whose information change triggered the onUserUpdate event.
    actor actor object Details of the person who modified the user information.
    changes model_changes object Changes that triggered onUserUpdate, specified as a JSON object of the following format.
    1
    2
    3
    { "user object field that changed": ["New value", "Old value"] }
    .

    Attributes of the user object
    ATTRIBUTE TYPE DESCRIPTION
    created_time string Timestamp of when the user information is created, specified in the UTC format.
    id string Identifier of the user. This is an auto-generated value when the user object is created.
    reference_id string Identifier of external references, such as email or phone number, input by the user.
    first_name string Business name of the user.
    last_name string Last name of the user.
    email string Email address of the user.
    avatar image object Image associated with the user.
    Attribute of the image object:
    url (string): Link from which the image is fetched.
    phone string Phone number of the user.
    properties array 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.
    Attributes of the property object:
    name (string): Name of the custom property.
    value (string): Value of the custom property.

    Attributes of the actor object
    ATTRIBUTE TYPE DESCRIPTION
    type string Descriptive identifier of the entity who updated the user details.
    Possible values: agent, user
    id string Identifier associated with the actor, either agent_id or user_id .
    first_name string Business name of the actor.
    last_name string Last name of the actor.
    email string Email address of the actor.
    avatar image object Image associated with the actor.
    Attribute of the image object:
    url (string): Link from which the image is fetched.
    Testing
    Notes:
    • To test a serverless app, use the latest version of Chrome.
    • As testing is only a simulation of events, actual data or record associated with the event is not created in the back-end. To create actual data and then test your event, publish your app as a custom app and test the events manually.
    • Ensure that the JSON files that contain the sample payloads to test events, are available at <app's root directory>/server/test_data.

    To simulate an event and test your app:

    1. From the command line, navigate to the directory that contains the app related files and run the following command.$ fdk run

    2. In the address bar of the browser, enter https://localhost:10001/web/test. A dialog box is displayed.

    3. Click Select an event. The list of all events configured in the server.js file is displayed.

    4. Select an event. The corresponding payload is displayed. To test a different scenario other than the default, edit the payload.

    5. Click Simulate. If the event is successfully simulated, the Simulate button changes to a Success button. If the event simulation fails because of invalid payload data, the Simulate button changes to a Failed button. Modify the payload appropriately and click Simulate.