Product Events

These are Freshdesk events, such as ticket create, ticket update, and conversation create, which can trigger apps. When product events occur, the appropriate method in the server.js file is invoked.

Note:
1. You need to have CLI v5.0.0 to use this feature. For more information on how to get the latest version, click here.
2. The serverless component of the app is executed in sandbox mode where some methods, such as setTimeout and setInterval, cannot be used.

Payload

When a supported product event occurs, the corresponding method in the server.js file is invoked and the following payload is passed to the app.

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

The following table lists the payload attributes.

Attribute Type Description
account_id number Freshdesk account ID.
domain string Freshdesk account domain.
event string Name of the event.
region string Region where the app is installed, will be either "US", "IND", "EUC", or "AUS".
timestamp number App installation timestamp in the epoch format.
iparams object Installation parameters.
Registration

When a product event occurs, an event listener is required for the appropriate method to be invoked. This is done in the following format.

server.js Copied Copy
1
2
3
4
5
6
7
8
9
exports = { events: [ { event: "eventName", callback: "eventCallbackMethod" } ], eventCallbackMethod: function(payload) { //Multiple events can access the same callback console.log("Logging arguments from the event: " + JSON.stringify(payload)); } }

Note:
1. Include the event and callback definition in the exports block.
2. Include only one callback method for an event.

onTicketCreate

When a new ticket is created, the onTicketCreate event is invoked and the registered callback method is executed. Use the following format to include this event in the server.js file.

Copied Copy
1
2
3
4
5
6
7
8
exports = { events: [ { event: "onTicketCreate", callback: "onTicketCreateCallback" } ], onTicketCreateCallback: function(payload) { console.log("Logging arguments from onTicketCreate event: " + JSON.stringify(payload)); } }
Sample Code Copied Copy
1
2
3
4
5
6
7
8
9
10
11
12
exports = { events: [ { event: "onTicketCreate", callback: "onTicketCreateCallback" } ], onTicketCreateCallback: function(payload) { console.log("Logging arguments from onTicketCreate event: " + JSON.stringify(payload)); if(payload.data.ticket.priority >= 3) { //your code goes here } } }
EXPAND ↓
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
{ "account_id" : 13, "domain" : "sample.freshdesk.com", "timestamp" : 1496400354326, "region" : "US", "event" : "onTicketCreate", "data" : { "ticket": { "subject": "Support Needed...", "description": "<div>Some details on the issue ..</div>", "is_description_truncated": false, "description_text": "Some details on the issue ...", "is_description_text_truncated": false, "due_by": "2015-07-14T13:08:06Z", "fr_due_by": "2015-07-14T13:08:06Z", "fr_escalated": false, "is_escalated": false, "fwd_emails": ["ram@freshdesk.com", "diana@freshdesk.com"], "reply_cc_emails": ["ram@freshdesk.com", "diana@freshdesk.com"], "email_config_id": 77123, "id": 1, "group_id": 351, "product_id": 1, "company_id": 2, "requester_id": 5483, "responder_id": 320, "tweet_id": "01234567890123456789", "status": 2, "priority": 1, "type": "Question", "tags": ["sales", "marketing"], "spam": false, "source": 2, "cc_emails": ["ram@freshdesk.com", "diana@freshdesk.com"], "to_emails": ["ram@freshdesk.com", "diana@freshdesk.com"], "created_at": "2015-07-09T13:08:06Z", "updated_at": "2015-07-09T13:08:06Z", "attachments": [ { "id": 9019290053, "content_type": "image/jpeg", "file_size": 78942, "name": "sample.jpg", "attachment_url": "https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/9019290053/original/sample.jpg", "created_at": "2016-12-22T09:37:47Z", "updated_at": "2016-12-22T09:37:47Z" } ] }, "requester": { "id": 5483, "name": "Rachel", "email": "rachel@freshdesk.com", "mobile": 7654367287, "phone": 4352789885, "language": "en", "created_at": "2015-08-28T09:08:16Z" } }, "iparams" : null }
EXPAND ↓

The following table lists the attributes of the ticket object.

ATTRIBUTE TYPE DESCRIPTION
attachments array of objects The ticket attachments.
created_at datetime Ticket creation timestamp in UTC format, YYYY-MM-DDTHH:MM:SSZ.
Example: 2016-02-13T23:27:49Z
company_id number ID of the company to which the ticket belongs.
cc_emails array of strings Email addresses added in the 'cc' field.
description string HTML content of the ticket description. This content will be truncated if it exceeds 10 KB.
is_description_truncated boolean Set to true if description is truncated.
description_text string Content of the ticket description in plain text. This content will be truncated if it exceeds 10 KB.
is_description_text_truncated boolean Set to true if description_text is truncated.
due_by datetime Timestamp, in UTC format, indicating when the ticket is to be resolved.
Example: 2016-02-13T23:27:49Z
email_config_id number ID of email config used for this ticket.
tweet_id string ID of Tweet that was converted into a ticket.
fr_due_by datetime Timestamp, in UTC format, indicating when the first response is due.
Example: 2016-02-13T23:27:49Z
fr_escalated boolean Set to true if the ticket has been escalated as a result of first response time being breached.
fwd_emails array of strings Email address(es) added when forwarding a ticket.
group_id number ID of the group to which the ticket is assigned.
id number ID of the ticket.
is_escalated boolean Set to true if the ticket has been escalated for any reason.
priority number Priority of the ticket.
product_id number ID of the product to which the ticket is associated.
reply_cc_emails array of strings Email address(es) added when replying to a ticket.
requester_id number ID of the requester. For existing contacts, requester_id can be passed instead of the requester's email.
responder_id number ID of the agent to whom the ticket is assigned.
source number The channel through which the ticket was created.
spam boolean Set to true if the ticket has been marked as spam.
status number Status of the ticket.
subject string Subject of the ticket.
tags array of strings Returns the list of tags for a ticket.
type string Helps categorize a ticket according to the different kinds of issues your support team deals with.
to_emails array of strings Email addresses to which the ticket was originally sent.
updated_at datetime Ticket updated timestamp in UTC format.
Example: 2016-02-13T23:27:49Z

Tickets use certain numbers to denote source, status, and priority. These numbers and their values are as follows.

Source Value
Email 1
Portal 2
Phone 3
Twitter 5
Facebook 6
Chat 7
Mobihelp 8
Feedback Widget 9
Outbound Email 10
Status Value
Open 2
Pending 3
Resolved 4
Close 5
Priority Value
Low 1
Medium 2
High 3
Urgent 4

The following table lists the attributes of the requester object.

ATTRIBUTE TYPE DESCRIPTION
id number ID of the requester.
name string Name of the requester.
email string Primary email of the requester.
mobile number Mobile number of the requester.
phone string Telephone number of the requester.
language string Language of the requester/contact; by default, language is 'en'.
created_at datetime Contact creation timestamp.
onTicketUpdate

When a ticket property is updated, the onTicketUpdate event is invoked and the registered callback method is executed.

The following ticket update events are supported:

  • Status changed
  • Priority changed
  • Group changed
  • Agent changed
  • Ticket deleted
  • Ticket is marked as spam
  • Type changed
  • Source changed
  • Ticket is escalated for any reason
  • Ticket is escalated because first response was breached

Note:
1. Replies or note additions are not considered ticket updates, you need to use the onConversationCreate event to handle them.
2. Ticket deletion is captured by the onTicketUpdate event and the deleted field is changed to true in the changes object.

Restrictions

The following changes will NOT trigger the onTicketUpdate event.

  • Updates to custom fields
  • Updates to tags

Use the following format to include the event in the server.js file.

Copied Copy
1
2
3
4
5
6
7
8
exports = { events: [ { event: "onTicketUpdate", callback: "onTicketUpdateCallback" } ], onTicketUpdateCallback: function(payload) { console.log("Logging arguments from onTicketUpdate event: " + JSON.stringify(payload)); } }

Sample Code Copied Copy
1
2
3
4
5
6
7
8
9
10
11
exports = { events: [ { event: "onTicketUpdate", callback: "onTicketUpdateCallback" } ], onTicketUpdateCallback: function(payload) { console.log("Logging arguments from onTicketUpdate event: " + JSON.stringify(payload)); //Finding fields that are changed var changes = payload.data.ticket.changes; //Your code goes here } }
EXPAND ↓

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
{ "account_id": 129, "domain": "fdm71.freshpacket.com", "timestamp" : 1496400354326, "region" : "US", "event": "onTicketUpdate", "data" : { "ticket": { "subject": "Support Needed...", "description": "<div>Some details on the issue ..</div>", "is_description_truncated": false, "description_text": "Some details on the issue ...", "is_description_text_truncated": false, "due_by": "2015-07-14T13:08:06Z", "fr_due_by": "2015-07-14T13:08:06Z", "fr_escalated": false, "is_escalated": false, "fwd_emails": ["ram@freshdesk.com", "diana@freshdesk.com"], "reply_cc_emails": ["ram@freshdesk.com", "diana@freshdesk.com"], "email_config_id": 77123, "id": 1, "group_id": 351, "product_id": 1, "company_id": 2, "requester_id": 5483, "responder_id": 320, "tweet_id": "01234567890123456789", "status": 2, "priority": 1, "type": "Question", "tags": ["sales", "marketing"], "spam": false, "source": 2, "cc_emails": ["ram@freshdesk.com", "diana@freshdesk.com"], "to_emails": ["ram@freshdesk.com", "diana@freshdesk.com"], "created_at": "2015-07-09T13:08:06Z" , "updated_at": "2015-07-09T13:08:06Z", "attachments": [ { "id": 9019290053, "content_type": "image/jpeg", "file_size": 78942, "name": "sample.jpg", "attachment_url": "https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/9019290053/original/sample.jpg", "created_at": "2016-12-22T09:37:47Z", "updated_at": "2016-12-22T09:37:47Z" } ], "changes": { "source": [2, 3], "priority": [1, 2] } }, "requester": { "id": 5483, "name": "Rachel", "email": "rachel@freshdesk.com", "mobile": 7654367287, "phone": 4352789885, "language": "en", "created_at": "2015-03-28T09:08:16Z" } }, "iparams": null }
EXPAND ↓

When a ticket is deleted, the deleted field is set to true as shown in the sample code.
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
{ "account_id": 129, "domain": "fdm71.freshpacket.com", "timestamp" : 1496400354326, "region" : "US", "event": "onTicketUpdate", "data": { "ticket": { "subject": "Support for ..", "description": "<div>Some details on the issue ..</div>", "is_description_truncated": false, "description_text": "Some details on the issue ...", "is_description_text_truncated": false, "due_by": 1484825400, "fr_due_by": "2017-01-17T17:00:00+05:30", "fr_escalated": false, "is_escalated": false, "fwd_emails": [], "reply_cc_emails": [], "email_config_id": null, "tweet_id": "01234567890123456789", "id":105, "group_id": null, "product_id": null, "company_id": null, "requester_id": 3877, "responder_id": null, "status": 6, "priority": 1, "type": null, "tags": null, "spam": false, "source": 3, "cc_emails": [], "to_emails": null, "created_at": 1484557933, "updated_at": "2017-01-17T17:52:18+05:30", "attachments": [], "changes": { "deleted": [false,true] } }, "requester": { "id": 3877, "name": "Regh", "email": "regh@gmail.com", "mobile": null, "phone": null, "language": "en", "created_at": "2015-03-28T09:08:16Z" } }, "iparams": null }
EXPAND ↓

The changes field is passed along with the payload.

The following table lists the attributes of the ticket object.

ATTRIBUTE TYPE DESCRIPTION
attachments array of objects The ticket attachments.
changes dictionary Updated keys with old and new values.
created_at datetime Ticket creation timestamp in UTC format.
Example: 2016-02-13T23:27:49Z
company_id number ID of the company to which this ticket belongs.
cc_emails array of strings Email addresses added in the 'cc' field of the incoming ticket email.
description string HTML content of the ticket description. This content will be truncated if it exceeds 10 KB.
is_description_truncated boolean Set to true if description is truncated.
description_text string Content of the ticket description in plain text. This content will be truncated if it exceeds 10 KB.
is_description_text_truncated boolean Set to true if description_text is truncated.
due_by datetime Timestamp, in UTC format, indicating when the ticket is due to be resolved.
Example: 2016-02-13T23:27:49Z
email_config_id number ID of email config which is used for this ticket.
tweet_id string ID of the Tweet that was converted into a ticket.
fr_due_by datetime Timestamp, in UTC format, indicating when the first response is due.
Example: 2016-02-13T23:27:49Z
fr_escalated boolean Set to true if the ticket has been escalated as a result of first response time being breached.
fwd_emails array of strings Email address(es) added when forwarding a ticket.
group_id number ID of the group to which the ticket has been assigned.
id number Unique ID of the ticket.
is_escalated boolean Set to true if the ticket has been escalated for any reason.
priority number Priority of the ticket.
product_id number ID of the product to which the ticket is associated.
reply_cc_emails array of strings Email address(es) added when replying to a ticket.
requester_id number User ID of the requester. For existing contacts, requester_id can be passed instead of the requester's email.
responder_id number ID of the agent to whom the ticket has been assigned.
source number The channel through which the ticket was created.
spam boolean Set to true if the ticket has been marked as spam.
status number Status of the ticket.
subject string Subject of the ticket.
tags array of strings Returns the list of tags for a ticket.
type string Helps categorize a ticket according to the different kinds of issues your support team deals with.
to_emails array of strings Email addresses to which the ticket was originally sent.
updated_at datetime Ticket updated timestamp in UTC format. Example: 2016-02-13T23:27:49Z

Ticket use certain numbers to denote source, status, and priority. These numbers and their values are as follows.

Source Value
Email 1
Portal 2
Phone 3
Twitter 5
Facebook 6
Chat 7
Mobihelp 8
Feedback Widget 9
Outbound Email 10
Status Value
Open 2
Pending 3
Resolved 4
Close 5
Priority Value
Low 1
Medium 2
High 3
Urgent 4

The following table lists the attributes of the requester object.

ATTRIBUTE TYPE DESCRIPTION
id number ID of the requester.
name string Name of the requester.
email string Primary email of the requester.
mobile number Mobile number of the requester.
phone string Telephone number of the requester.
language string Language of the requester/contact; by default, language is 'en'.
created_at datetime Contact creation timestamp.
onConversationCreate

When a reply or note is added to a ticket, the onConversationCreate event is invoked and the registered callback method is executed.

The supported conversation create events are:

  • Reply added
  • Public note added
  • Private note added

Use the following format to include the event in the server.js file.

Copied Copy
1
2
3
4
5
6
7
8
exports = { events: [ { event: "onConversationCreate", callback: "onConversationCreateCallback" } ], onConversationCreateCallback: function(payload) { console.log("Logging arguments from onConversationCreate event: " + JSON.stringify(payload)); } }

Sample Reply 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
{ "account_id" : 13, "domain" : "http://sample.freshdesk.com", "timestamp" : 1496400354326, "region" : "US", "event" : "onConversationCreate", "data": { "conversation": { "body": "<div>Hi tom, Still Angry</div>", "is_body_truncated": false, "body_text": "Hi tom, Still Angry", "is_body_text_truncated": false, "id": 5, "from_email": "rachel@freshdesk.com", "bcc_emails": ["ram@freshdesk.com", "diana@freshdesk.com"], "support_email": "rachel@freshdesk.com", "user_id": 23423, "ticket_id": 452, "private": false, "incoming": false, "source": 0, "cc_emails": null, "to_emails": ["ram@freshdesk.com", "diana@freshdesk.com"], "created_at": "2015-07-09T13:08:06Z", "updated_at": "2015-07-09T13:08:06Z", "attachments": [ { "id": 9019290053, "content_type": "image/jpeg", "size": 78942, "name": "sample.jpg", "attachment_url": "https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/9019290053/original/sample.jpg", "created_at": "2016-12-22T09:37:47Z", "updated_at": "2016-12-22T09:37:47Z" } ] } }, "iparams" : null, }
EXPAND ↓

Sample Public Note 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
{ "account_id" : 13, "domain" : "http://sample.freshdesk.com", "timestamp" : 1496400354326, "region" : "US", "event" : "onConversationCreate", "data": { "conversation": { "body": "<div>Hi tom, Still Angry</div>", "is_body_truncated": false, "body_text": "Hi tom, Still Angry", "is_body_text_truncated": false, "id": 5, "from_email": null, "bcc_emails": [], "support_email": null, "user_id": 23423, "ticket_id": 452, "private": false, "incoming": false, "source": 2, "cc_emails": null, "to_emails": [], "created_at": "2015-07-09T13:08:06Z", "updated_at": "2015-07-09T13:08:06Z", "attachments": [] } }, "iparams" : null }
EXPAND ↓

Sample Private Note 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
{ "account_id" : 13, "domain" : "http://sample.freshdesk.com", "timestamp" : 1496400354326, "region" : "US", "event" : "onConversationCreate", "data": { "conversation": { "body": "<div>Hi tom, Still Angry</div>", "is_body_truncated": false, "body_text": "Hi tom, Still Angry", "is_body_text_truncated": false, "id": 5, "from_email": null, "bcc_emails": [], "support_email": null, "user_id": 23423, "ticket_id": 452, "private": true, "incoming": true, "source": 2, "cc_emails": null, "to_emails": [], "created_at": "2015-07-09T13:08:06Z", "updated_at": "2015-07-09T13:08:06Z", "attachments": [] } }, "iparams" : null }
EXPAND ↓

The following table lists the attributes of the conversation object.

ATTRIBUTE TYPE DESCRIPTION
attachments array of objects Attachments associated with the conversation.
body string Content of the conversation in HTML. This content is truncated if it exceeds 10 KB.
is_body_truncated boolean Set to true if the body is truncated.
body_text string Content of the conversation in plain text. This content is truncated if it exceeds 10 KB.
is_body_text_truncated boolean Set to true if the body_text is truncated.
bcc_emails array of strings Email address added in the 'bcc' field of the outgoing ticket email.
cc_emails array of strings Email addresses added in the 'cc' field of the incoming ticket email.
created_at datetime Conversation creation timestamp in UTC format, YYYY-MM-DDTHH:MM:SSZ. Example: 2016-02-13T23:27:49Z
from_email string The email address from which the reply is sent. By default, the global support email is used.
id number ID of the conversation.
incoming boolean Set to true if a particular conversation should appear as being created from outside (i.e., not through a web portal).
private boolean Set to true if it is a private note.
source number Denotes the type of conversation.
supporting_email string Email address from which the reply is sent. For notes, this value will be null.
ticket_id number ID of the ticket to which the conversation is being added.
to_emails array of strings Email addresses of agents/users who need to be notified about this conversation.
updated_at datetime Ticket updated timestamp in UTC format. Example: 2016-02-13T23:27:49Z
user_id number ID of the agent/user who is adding the conversation.

Every conversation uses certain numbers to denote its source. These numbers and their values are listed.

Source Value
Reply 0
Note 2
Created from tweets 5
Created from survey feedback 6
Created from Facebook post 7
Source Value
Created from forwarded email 8
Created from phone 9
Created from Mobihelp 10
E-Commerce 11
onContactCreate

When a contact is created, the onContactCreate event is invoked and the registered callback method is executed.

Use the following format to include the event in the server.js file.

Copied Copy
1
2
3
4
5
6
7
8
exports = { events: [ { event: "onContactCreate", callback: "onContactCreateCallback" } ], onContactCreateCallback: function(payload) { console.log("Logging arguments from onContactCreate event: " + JSON.stringify(payload)); } }

Sample Code Copied Copy
1
2
3
4
5
6
7
8
9
10
exports = { events: [ { event: "onContactCreate", callback: "onContactCreateCallback" } ], onContactCreateCallback: function(payload) { console.log("Logging arguments from onContactCreate event: " + JSON.stringify(payload)); //Print the new contact and email. console.log("Contact name - ", payload.data.contact.name, "\n email - ", payload.data.contact.email); } }
EXPAND ↓

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
{ "account_id" : 13, "domain" : "http://sample.freshdesk.com", "timestamp" : 1496400354326, "region" : "US", "event" : "onContactCreate", "data": { "contact": { "active": false, "address": "221 B, Baker Street, London.", "company_id": 1, "description": "Sherlocks contact details.", "email": "superman@freshdesk.com", "id": 2, "job_title": "Investigator", "language": "en", "mobile": 3545643254, "name": "Sherlock Holmes", "phone": "98765315", "time_zone": "London", "twitter_id": "234xsdf", "other_emails": ["lex@freshdesk.com","louis@freshdesk.com"], "created_at": "2015-08-28T09:08:16Z", "updated_at": "2015-08-28T09:08:16Z", "tags": ["marketing"], "custom_fields": { "external_id": 1289 } } }, "iparams" : null }
EXPAND ↓

The following table lists the attributes of the contactobject.

ATTRIBUTE TYPE DESCRIPTION
active boolean Set to true if the contact has been verified.
address string Address of the contact.
company_id number ID of the company to which this contact belongs.
custom_fields object Key value pairs containing the names and values of custom fields.
description string Description of the contact.
email string Primary email address of the contact. If you want to associate additional email(s) with this contact, use the other_emails attribute.
id number ID of the contact.
job_title string Job title of the contact.
language string Language of the requester/contact, by default, language is 'en'.
mobile number Mobile number of the contact.
name string Name of the contact.
phone string Telephone number of the contact.
time_zone string Time zone of the contact. Default value is the time zone of the domain. This attribute can be set if the Multiple Time Zone feature is enabled (Garden plan and above).
other_emails array of strings Additional emails associated with the contact.
twitter_id string Twitter handle of the contact.
created_at datetime Creation timestamp.
updated_at datetime Last modification timestamp.
tags array of strings Tags associated with this contact.
onContactUpdate

When a contact is updated, the onContactUpdate event is invoked and the registered callback method is executed.

The following contact update events are supported:

  • Contact details changed
  • Contact deleted
  • Contact blocked
  • Contact whitelisted
  • Contact tags added/updated/deleted
  • Contact activated

Note:
This event is not triggered when an existing contact is converted to an agent.

Use the following format to include the event in the server.js file.

Copied Copy
1
2
3
4
5
6
7
8
exports = { events: [ { event: "onContactUpdate", callback: "onContactUpdateCallback" } ], onContactUpdateCallback: function(payload) { console.log("Logging arguments from onContactUpdate event: " + JSON.stringify(payload)); } }

Sample Code Copied Copy
1
2
3
4
5
6
7
8
9
10
11
exports = { events: [ { event: "onContactUpdate", callback: "onContactUpdateCallback" } ], onContactUpdateCallback: function(payload) { console.log("Logging arguments from onContactUpdate event: " + JSON.stringify(payload)); //Finding fields that are changed. var changes = payload.data.contact.changes; // Your code to work with changes. } }
EXPAND ↓

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
{ "account_id" : 13, "domain" : "http://sample.freshdesk.com", "timestamp" : 1496400354326, "region" : "US", "events" : "onContactUpdate", "data": { "contact": { "active": false, "address": "221 B, Baker Street, London.", "company_id": 1, "description": "Sherlocks contact details.", "email": "superman@freshdesk.com", "id": 2, "job_title": "Investigator", "language": "en", "mobile": 3545643254, "name": "Sherlock Holmes", "phone": "987653151", "time_zone": "London", "twitter_id": "234xsdf", "other_emails": ["lex@freshdesk.com","louis@freshdesk.com"], "created_at": "2015-08-28T09:08:16Z", "updated_at": "2015-08-28T09:08:16Z", "tags": ["marketing"], "custom_fields": { "external_id": 1289 }, "changes": { "phone": ["98765315", "987653151"] } } }, "iparams" : null }
EXPAND ↓

The changes field is passed along with the payload.

When a contact is deleted, the deleted field is set to true as shown in the sample code.

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
{ "account_id" : 13, "domain" : "http://sample.freshdesk.com", "timestamp" : 1496400354326, "region" : "US", "events" : "onContactUpdate", "data": { "contact": { "active": false, "address": "221 B, Baker Street, London.", "company_id": 1, "description": "Sherlocks contact details.", "email": "superman@freshdesk.com", "id": 2, "job_title": "Investigator", "language": "en", "mobile": 3545643254, "name": "Sherlock Holmes", "phone": "987653151", "time_zone": "London", "twitter_id": "234xsdf", "other_emails": ["lex@freshdesk.com","louis@freshdesk.com"], "created_at": "2015-08-28T09:08:16Z", "updated_at": "2015-08-28T09:08:16Z", "tags": ["marketing"], "custom_fields": { "external_id": 1289 }, "changes": { "deleted": [false,true] } } }, "iparams" : null }
EXPAND ↓

The following table lists the attributes of the contact object.

ATTRIBUTE TYPE DESCRIPTION
active boolean Set to true if the contact has been verified.
address string Address of the contact.
changes dictionary Updated keys with old and new values.
company_id number ID of the company to which this contact belongs.
custom_fields object Key value pairs containing names and values of custom fields.
description string Description of the contact.
email string Primary email address of the contact. If you want to associate additional email(s) with this contact, use the other_emails attribute.
id number ID of the contact.
job_title string Job title of the contact.
language string Language of the requester/contact, by default, language is 'en'.
mobile number Mobile number of the contact.
name string Name of the contact.
phone string Telephone number of the contact.
time_zone string Time zone of the contact. Default value is the time zone of the domain. This attribute can be set if the Multiple Time Zone feature is enabled (Garden plan and above).
other_emails array of strings Additional emails associated with the contact.
twitter_id string Twitter handle of the contact.
created_at datetime Creation timestamp.
updated_at datetime Last modification timestamp.
tags array of strings Tags associated with this contact.
onCompanyCreate

When a company is created, the onCompanyCreate event is invoked and the registered callback method is executed.

Use the following format to include the event in the server.js file.

Copied Copy
1
2
3
4
5
6
7
8
exports = { events: [ { event: "onCompanyCreate", callback: "onCompanyCreateCallback" } ], onCompanyCreateCallback: function(payload) { console.log("Logging arguments from onCompanyCreate 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
{ "account_id" : 13, "domain" : "http://sample.freshdesk.com", "timestamp" : 1496400354326, "region" : "US", "event" : "onCompanyCreate", "data": { "company": { "id": 26782, "name": "Acme Inc.", "description": "Fictional Company", "domains": ["acmeinc.com"], "note": "Sales division of Acme", "created_at": "2018-10-24 06:10:46", "updated_at": "2018-10-24 06:10:46", "health_score": "Happy", "account_tier": "Premium", "renewal_date": "2020-12-31T00:00:00Z", "industry": "Aerospace" }, "actor": { "id": 483, "name": "Jason", "email": "jason@freshdesk.com" } }, "iparams" : null }
EXPAND ↓

The following table lists the attributes of the companyobject.

ATTRIBUTE TYPE DESCRIPTION
id number Unique ID of the company.
name string Name of the company.
description string Description of the company.
domains array Domains of the company. Email addresses of contacts that contain this domain will be associated with that company automatically.
note string Any specific note about the company.
created_at datetime Creation timestamp.
updated_at datetime Last modified timestamp.
health_score string The strength of your relationship with the company.
account_tier string Classification based on how much value the company brings to your business.
renewal_date date Date when your contract or relationship with the company is due for renewal.
industry string The industry the company serves in.
onCompanyUpdate

When a company is updated, the onCompanyUpdate event is invoked and the registered callback method is executed.

Updates to the following fields trigger this event:

  • Name
  • Description

Use the following format in the server.js file to listen for the event.

Copied Copy
1
2
3
4
5
6
7
8
exports = { events: [ { event: "onCompanyUpdate", callback: "onCompanyUpdateCallback" } ], onCompanyUpdateCallback: function(payload) { console.log("Logging arguments from onCompanyUpdate 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
{ "account_id" : 13, "domain" : "http://sample.freshdesk.com", "timestamp" : 1496400354326, "region" : "US", "event" : "onCompanyUpdate", "data": { "company": { "id": 26782, "name": "Acme Inc.", "description": "Fictional Company", "domains": ["acmeinc.com"], "note": "Sales division of Acme", "created_at": "2018-10-24 06:10:46", "updated_at": "2018-10-24 06:10:46", "health_score": "Happy", "account_tier": "Premium", "renewal_date": "2020-12-31T00:00:00Z", "industry": "Aerospace" "changes": { "description": ["Fictional Company", "Space Shuttle Manufacturing"] } }, "actor": { "id": 483, "name": "Jason", "email": "jason@freshdesk.com" } }, "iparams" : null }
EXPAND ↓

The changes field is passed along with the payload.

The following table lists the attributes of the company object.

ATTRIBUTE TYPE DESCRIPTION
id number Unique ID of the company.
name string Name of the company.
description string Description of the company.
domains array Domains of the company. Email addresses of contacts that contain this domain will be associated with that company automatically.
note string Any specific note about the company.
created_at datetime Creation timestamp.
updated_at datetime Last modified timestamp.
health_score string The strength of your relationship with the company.
account_tier string Classification based on how much value the company brings to your business.
renewal_date date Date when your contract or relationship with the company is due for renewal.
industry string The industry the company serves in.
onCompanyDelete

When a company is deleted, the onCompanyDelete event is invoked and the registered callback method is executed.

Use the following format in the server.js file to listen for the event.

Copied Copy
1
2
3
4
5
6
7
8
exports = { events: [ { event: "onCompanyDelete", callback: "onCompanyDeleteCallback" } ], onCompanyDeleteCallback: function(payload) { console.log("Logging arguments from onCompanyDelete event: " + JSON.stringify(payload)); } }

Sample Payload
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{ "data": { "company": { "id" : 26782, "name" : "Acme Inc." }, "actor": { "id": 483, "name": "Jason", "email": "jason@freshdesk.com" } }, "timestamp" : 1496400354326, "account_id": 13, "domain": "sample.freshdesk.com", "event": "onCompanyDelete", "region": "US" }
EXPAND ↓

onTimeEntryCreate

When a new time entry is created, the onTimeEntryCreate event is invoked and the registered callback method is executed.

Use the following format in the server.js file to listen for the event.

Copied Copy
1
2
3
4
5
6
7
8
9
exports = { events: [ { event: "onTimeEntryCreate", callback: "onTimeEntryCreateCallback" } ], onTimeEntryCreateCallback: function(payload) { console.log("Logging arguments from onTimeEntryCreate event: " + JSON.stringify(payload)); console.log("Time Entry Note- ", payload.data.time_entry.note, "\n Agent Name - ", payload.data.actor.name); } }

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
{ "account_id" : 13, "domain" : "http://sample.freshdesk.com", "timestamp" : 1496400354326, "region" : "US", "event" : "onTimeEntryCreate", "data": { "time_entry": { "id" : 2, "billable" : true, "note" : "Invoice Preparation", "timer_running" : false, "agent_id" : 54, "ticket_id" : 20, "time_spent" : "10:40", "created_at" : "2015-08-25T07:31:55Z", "updated_at" : "2015-08-25T07:31:55Z", "start_time" : "2015-08-25T07:31:55Z", "executed_at" : "2015-08-25T07:31:55Z" }, "actor": { "id": 483, "name": "Jason", "email": "jason@freshdesk.com" }, "agent": { "id": 54, "name": "Rachel", "email": "rachel@freshdesk.com" } }, "iparams" : null }
EXPAND ↓

The following table lists the attributes of the time_entryobject.

ATTRIBUTE TYPE DESCRIPTION
id number Unique ID of the time entry.
billable boolean Set to true if the time entry is billable.
note string Description of the time entry.
timer_running boolean Set to true if the timer is currently running.
agent_id number The ID of the agent to whom this time entry is associated.
ticket_id number The ID of the ticket to which this time entry is associated.
time_spent string The duration in hh:mm format.
created_at datetime Creation timestamp.
updated_at datetime Last modified timestamp.
start_time datetime The time at which the time entry is added or the time of the last invoked 'start-timer' action using a toggle.
executed_at datetime Time at which this time entry was added/created.
onTimeEntryUpdate

When a time entry is updated, the onTimeEntryUpdate event is invoked and the registered callback method is executed.

Updates to the following fields trigger this event:

  • agent_id
  • billable
  • executed_at
  • note
  • start_time
  • time_spent
  • timer_running

Use the following format in the server.js file to listen for the event.

Copied Copy
1
2
3
4
5
6
7
8
exports = { events: [ { event: "onTimeEntryUpdate", callback: "onTimeEntryUpdateCallback" } ], ononTimeEntryUpdateCallback: function(payload) { console.log("Logging arguments from onTimeEntryUpdate 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
{ "account_id" : 13, "domain" : "http://sample.freshdesk.com", "timestamp" : 1496400354326, "region" : "US", "events" : "onTimeEntryUpdate", "data": { "time_entry": { "id" : 2, "billable" : true, "note" : "Invoice Preparation", "timer_running" : false, "agent_id" : 1, "ticket_id" : 20, "time_spent" : "10:40", "created_at" : "2015-08-25T07:31:55Z", "updated_at" : "2015-08-25T07:31:55Z", "start_time" : "2015-08-25T07:31:55Z", "executed_at" : "2015-08-25T07:31:55Z", "changes": { "billable": [false, true], "time_spent": [1200, 1500] } }, "actor": { "id": 483, "name": "Jason", "email": "jason@freshdesk.com" }, "agent": { "id": 54, "name": "Rachel", "email": "rachel@freshdesk.com" } }, "iparams" : null }
EXPAND ↓

The changes field is passed along with the payload.

The following table lists the attributes of the time_entryobject.

ATTRIBUTE TYPE DESCRIPTION
id number Unique ID of the time entry.
billable boolean Set to true if the time entry is billable.
note string Description of the time entry.
timer_running boolean Set to true if the timer is currently running.
agent_id number The ID of the agent to whom this time entry is associated.
ticket_id number The ID of the ticket to which this time entry is associated.
time_spent string The duration in hh:mm format.
created_at datetime Creation timestamp.
updated_at datetime Last modified timestamp.
start_time datetime The time at which the time entry is added or the time of the last invoked 'start-timer' action using a toggle.
executed_at datetime Time at which this time entry was added/created.
onTimeEntryDelete

When a time entry is deleted, the onTimeEntryDelete event is invoked and the registered callback method is executed.

Use the following format in the server.js file to listen for the event.

Copied Copy
1
2
3
4
5
6
7
8
exports = { events: [ { event: "onTimeEntryDelete", callback: "onTimeEntryDeleteCallback" } ], onTimeEntryDeleteCallback: function(payload) { console.log("Logging arguments from onTimeEntryDelete 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
{ "account_id" : 13, "domain" : "http://sample.freshdesk.com", "timestamp" : 1496400354326, "region" : "US", "event" : "onTimeEntryDelete", "data": { "time_entry": { "id" : 2, "ticket_id" : 20 }, "actor": { "id": 483, "name": "Jason", "email": "jason@freshdesk.com" } }, "iparams" : null }
EXPAND ↓

Testing

Note: For testing, we recommend that you use the latest version of Chrome browser.

You can easily test your app in your machine by simulating events. Also, you can test different scenarios by directly modifying the payload.

Note: As the testing is only a simulation of events, an actual event will not be recorded in the back end. If you need an actual ticket/contact to be created, then it is recommended to publish your app as a custom app and test the operation manually.

To simulate events for testing, follow the given procedure.

  1. In your console, navigate to your project directory, and execute the following command. $ fdk run
  2. Open your browser and enter the following URL to start testing your app: http://localhost:10001/web/events.
  3. Select the event that you want to simulate.
  4. Once you select an event, the corresponding event payload is displayed. Edit the values and then click Simulate. When you edit the payload, ensure that you adhere to the JSON format.
  5. If the event is successfully simulated, Success is displayed.
  6. If there is a problem, Failed is displayed. Check if the payload is valid and then resume testing.