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,
- 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.
- 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.
Contact details page
An app deployed on the Contact details page can use the client.data.get(<objectName>) data method and retrieve the following objects:
contact
Use the sample code shown on the right pane > Sample code tab, to retrieve information of a contact in the contact details page.
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 whether 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
company
Use the sample code shown on the right pane > Sample code tab, to retrieve information of a company in the contact details page.
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.