Use data method

Data method is an interface that the developer platform provides to enable your app to retrieve product data (in the form of JSON payloads).

When an app is initialized successfully, the parent app (Freshworks product) passes a client reference to your app. Your app can use this reference and the developer platform’s data method to retrieve the different objects on the Freshworks product UI, as payloads.

To enable your app to retrieve product data, in the app.js file,

  1. Subscribe to the app.initialized event, through an event listener. When the app is initialized, the parent application passes a client reference to the app.
  2. After app initialization, use the data method - client.data.get(<objectName>) - to retrieve the specified object (<objectName>) from the product UI.

As part of the app logic, your app can process the retrieved payload to derive meaningful results.

This section,

  • Lists all the objects that can be retrieved by using the data method.
  • Describes all the attributes of the retrieved object.

Data objects accessible from all pages

These objects are available in all pages of the product UI. Irrespective of the page on which the app is deployed, when you use the data method -client.data.get(<objectName>)- and retrieve these objects, the corresponding payload is retrieved.

An app can retrieve the following objects irrespective of where the app is deployed:

currentHost

A global app, with module-specific app logic, can be deployed on various Freshworks products. currentHost refers to the Freshworks product on which the app is currently running. Based on the currentHost, from the back-end, we retrieve the modules that the app user working on the currentHost has subscribed to. Based on the subscribed modules, we can retrieve the product-specific urls that the app built for the modules can use, to access the product resources.

For more information on currentHost, see Global app concepts.

Use the sample code shown on the right pane > Sample code tab, to retrieve the currentHost object that contains information on,

  • All modules that the app user using the currentHost has access to and applicable to the app.
  • All product names and the corresponding account urls through which the app built for the subscribed modules can access product resources.

Attributes of the currentHost object

  • subscribed_modulesarray of strings

    All modules that the app user has subscribed to and present in the app manifest.

  • endpoint_urlsobject

    Product name and account url (domain name) to access product resources, specified as a key (product name) - value (account URL) pair.

    You can use the domain name to construct api calls that can access product resources.

loggedInUser

Use the sample code shown on the right pane > Sample code tab, to retrieve information on the agent logged into the Freshworks product UI.

Attributes of the loggedInUser object

  • idinteger

    Identifier of the agent, auto-generated when the agent’s information is configured in the system.

  • created_atstring

    Timestamp of when the agent’s record was created in the Freshworks product system, specified in the UTC format.

  • updated_atstring

    Timestamp of when the agent’s record is last updated in the Freshworks product system, specified in the UTC format.

  • availableboolean

    Specifies whether the agent is available for ticket assignment.

    Possible values: true, false

  • available_sincestring

    Timestamp of since when the agent has been available for ticket assignment.

  • abilitiesarray of strings

    List of the access privileges granted to the agent, specified as an array. For example, create and edit topics, export tickets, and so on.

  • contactobject

    Details of the contact record configured for the agent in the Freshworks product system.

  • group_idsarray of integers

    Identifiers of the groups to which the agent is associated, specified as an array.

  • occasionalboolean

    Specifies whether the agent is an occasional agent or a full-time agent .

    Possible values: true, false

  • role_idsarray of integers

    Identifiers of the roles associated with the agent, which determine the access privileges of the agent.

  • signaturestring

    HTML format of the personalized message block appended to the emails/replies that the agent sends.

  • ticket_scopeinteger

    Permission granted to the agent to access the tickets in the Freshworks product system.

    Possible values:

    1: The agent can access all tickets created in the Freshworks product system.

    2: The agent can access tickets assigned to the agent or to the group(s) to which the agent belongs.

    3: The agent can only access tickets assigned to the agent.

Ticket details page

An app deployed on the Ticket details page can use the client.data.get(<objectName>) data method and retrieve the following objects:

ticket

Use the sample code shown on the right pane > Sample code tab, to retrieve information of a ticket.

Attributes of the ticket object

  • idinteger

    Identifier of the ticket, auto-generated when a ticket is created in the system.

  • created_atstring

    Timestamp of when the ticket was created in the Freshdesk system, specified in the UTC format.

  • updated_atstring

    Timestamp of when the ticket was last updated in the Freshdesk system, specified in the UTC format.

  • subjectstring

    Subject of the ticket created in the Freshdesk system.

  • descriptionstring

    Summary of the issue raised in the ticket, in HTML format.

  • description_textstring

    Summary of the issue raised in the ticket, in plain text format.

  • statusinteger

    Status of the ticket in the Freshdesk system. The default statuses in Freshdesk are,

    2: Open

    3: Pending

    4: Resolved

    5: Closed

    6: Waiting on customer

    7: Waiting on third party

  • status_typestring

    Type of ticket status associated with the ticket.

  • priorityinteger

    Priority assigned to the ticket.

    Possible values:

    1: Low priority

    2: Medium priority

    3: High priority

    4: Urgent

  • priority_labelstring

    Type of priority assigned to the ticket.

  • attachmentsarray of objects

    Details of the documents attached to the ticket.

  • to_emailsarray of strings

    Additional email addresses that are copied when the ticket is created with email as the source.

  • cc_emailsarray of strings

    Additional email addresses that are copied when the ticket is created with email as the source, specified as an array.

  • reply_cc_emailsarray of strings

    Additional email addresses that an agent adds when replying to a ticket, specified as an array.

  • fwd_emailsarray of strings

    Additional email addresses that an agent adds when forwarding a ticket, specified as an array.

  • company_idinteger

    Identifier of the company to which the contact associated with the ticket belongs.

  • custom_fieldsarray of objects

    Custom field names and corresponding values configured in the Freshdesk system to obtain additional ticket information, specified as a valid JSON object of key (custom field name)-value (custom field’s value) pairs.

  • due_bystring

    Timestamp of when the ticket is to be resolved, specified in the UTC format.

  • fr_due_bystring

    Timestamp of when the first response is due for the ticket, specified in the UTC format.

  • fr_escalatedboolean

    Specifies whether the ticket has been escalated for delay in sending the first response.

    Possible values: true, false

  • is_escalatedboolean

    Specifies whether the ticket is escalated for any reason.

    Possible values: true, false

  • email_config_idinteger

    Identifier of the customized email address, which is configured to automatically create a new ticket from the email received to the support email.

  • group_idinteger

    Identifier the group to which the ticket is associated.

  • product_idinteger

    Identifier of the product to which the ticket is associated, if an organization has configured multiple products.

  • requester_idinteger

    Identifier of the requester who created the ticket.

  • responder_idinteger

    Identifier of the agent to whom the ticket is assigned.

  • sourceinteger

    Identifies the channel through which the ticket is created. The default channels in Freshdesk and the corresponding values are,

    1: Email

    2: Portal

    3: Phone

    4: Forum

    5: Twitter

    6: Facebook

    7: Chat widget in the Freshdesk system

    9: Feedback widget in the Freshdesk system

    10: Outbound email sent by an agent to the customer

    11: E-commerce

    In addition to the default sources defined in the Freshdesk system, new channels can be added.

  • source_typestring

    Name of the source that triggered the ticket event.

  • spamboolean

    Specifies whether the ticket is spam.

    Possible values: true, false

  • statsobject

    Identifier the group to which the ticket is associated.

  • tagsarray of strings

    Keywords associated with the ticket.

  • typestring

    Category of issue the ticket is addressing. For example, Feature request, Refund, and so on.

contact

Use the sample code shown on the right pane > Sample code tab, to retrieve information of a contact.

Attributes of the contact object

  • idinteger

    Identifier of the contact object, auto-generated when a contact record is created in the Freshdesk system.

  • created_atstring

    Timestamp of when the contact was created in the Freshdesk system, specified in the UTC format.

  • updated_atstring

    Timestamp of when the contact details were last updated in the Freshdesk system, specified in the UTC format.

  • namestring

    Full name of the contact.

  • emailstring

    Email address of the contact specified when the contact information is created in the Freshdesk system.

  • other_emailsarray of strings

    Additional email addresses of the contact.

  • mobilestring

    Mobile phone number of the contact.

  • phonestring

    Official phone number of the contact.

  • activeboolean

    Specifies whether the contact is active in the Freshdesk system. Possible values: true, false

  • addressstring

    Residential address of the contact, as specified in the Freshdesk system.

  • avatarobject

    Details of the image used as the avatar in the company profile.

  • descriptionstring

    Details about the contact, specified when the contact information is created in the Freshdesk system.

  • is_agentboolean

    Specifies whwther the contact is configured as an agent in the Freshdesk system.

    Possible values: true, false

  • job_titlestring

    Designation of the contact in the company to which the contact belongs.

  • languagestring

    Primary language of the contact, in the ISO-639 code.

  • other_companiesarray of objects

    Additional companies associated with the contact.

  • tagsarray of strings

    Keywords associated with a contact. The keywords help to filter a subset of contacts from all contacts in the system.

  • time_zonestring

    Time zone to which the contact belongs, in an easily consumable (RAILS timezone.name) format.

  • twitter_idstring

    Identifier of the contact’s twitter account.

  • view_all_ticketsboolean

    Specifies whether the contact can view all the tickets associated with the company.

    Possible values: true, false

email_config

Use the sample code shown on the right pane > Sample code tab, to retrieve a list of email configurations for a user.

Note:You can retrieve up to 100 email-configs using the data method.

Attributes of the email_config object

  • idinteger

    Identifier of the customized email address, which is configured to automatically create a new ticket from the email received to the support email.

  • replyEmailstring

    Email address used when replying to an email.

  • namestring

    Full name of the contact.

  • toEmailstring

    Forwarding email address of the email_config object.

  • primaryRoleboolean

    Specifies whether the email in the email_config object is marked as primary in Admin -> Email Settings. Possible values: true, false

  • groupIdinteger

    Identifier the group to which the ticket is associated.

  • productIdinteger

    Identifier of the product to which the ticket is associated, if an organization has configured multiple products.

requester

Use the sample code shown on the right pane > Sample code tab, to retrieve information of a requester.

Attributes of the requester object

  • idinteger

    Identifier of the requester object, auto-generated when a new requester is added to the Freshdesk system.

  • created_atstring

    Timestamp of when the requester object was created in the Freshdesk system, specified in the UTC format.

  • updated_atstring

    Timestamp of when the requester object was last updated in the Freshdesk system, specified in the UTC format.

  • namestring

    Full name of the requester.

  • emailstring

    Email address of the requester specified when the requester information is created in the Freshdesk system.

  • other_emailsarray of strings

    Additional email addresses of the requester.

  • mobilestring

    Mobile phone number of the requester.

  • phonestring

    Official phone number of the requester.

  • activeboolean

    Specifies whether the requester is active in the Freshdesk system. Possible values: true, false

  • addressstring

    Residential address of the requester, as specified in the Freshdesk system.

  • avatarobject

    Details of the image used as the avatar.

  • descriptionstring

    Details about the requester, specified when the requester information is created in the Freshdesk system.

  • is_agentboolean

    Specifies whether the requester is configured as an agent in the Freshdesk system.

    Possible values: true, false

  • job_titlestring

    Designation of the contact in the company to which the contact belongs.

  • languagestring

    Primary language of the requester, in the ISO-639 code.

  • other_companiesarray of objects

    Additional companies associated with the contact.

  • tagsarray of strings

    Keywords associated with a requester. The keywords help to filter a subset of contacts from all contacts in the system.

  • time_zonestring

    Time zone to which the requester belongs, in an easily consumable (RAILS timezone.name) format.

  • twitter_idstring

    Identifier of the requester’s twitter account.

  • view_all_ticketsboolean

    Specifies whether the requester can view all the tickets associated with the company.

    Possible values: true, false

company

Use the sample code shown on the right pane > Sample code tab, to retrieve information of a company.

Attributes of the company object

  • idinteger

    Identifier of the company object, auto-generated when a company record is created in the Freshdesk system.

  • namestring

    Registered name of the company that is specified when creating a company or contact in Freshdesk system.

  • avatarstring

    Details of the image used as the avatar in the company profile.

  • view_all_ticketsboolean

    Specifies whether the contact can view all the tickets associated with the company.

    Possible values: true, false

group

Use the sample code shown on the right pane > Sample code tab, to retrieve information of the agent group.

Attributes of the group object

  • idinteger

    Identifier of the group object, auto-generated when a new agent group is configured in the Freshdesk system.

  • namestring

    Name of the group.

  • agent_idsarray of integers

    Identifiers of the agents associated with the group, specified as an array.

<field-name>_options

Use the sample code shown on the right pane to retrieve all configured options (field values) of the following drop-down fields.

For both custom and default drop-down fields, you can retrieve the options by adding the suffix _options to the field name and using it as the objectName in the client.data.get(<objectName>) data method. This returns an array of the field values.

Note:You can retrieve the field values available on Ticket details page only.

Field nameSyntax
Statusclient.data.get("status_options")
Priorityclient.data.get("priority_options")
Typeclient.data.get("ticket_type_options")
Custom Fieldclient.data.get("customfield_options")

time_entry

Use the sample code shown on the right pane > Sample code tab, to retrieve the time entry details of an agent.

Attributes of the time_entry object

  • time_entriesarray of objects

    Details of the time logs entered for the ticket in the Freshdesk system.

New ticket page

An app deployed on the New ticket page can use the client.data.get(<objectName>) data method and retrieve the following object:

<field-name>_options

Use the sample code shown on the right pane to retrieve all configured options (field values) of the following drop-down fields.

For both custom and default drop-down fields, you can retrieve the options by adding the suffix _options to the field name and using it as the objectName in the client.data.get(<objectName>) data method. This returns an array of the field values.

Note:You can retrieve the field values available on the New ticket page only.

Field nameSyntax
Statusclient.data.get("status_options")
Priorityclient.data.get("priority_options")
Typeclient.data.get("ticket_type_options")
Custom Fieldclient.data.get("customfield_options")