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 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.
loggedInAgent
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 loggedInAgent object
- idinteger
Identifier of the agent, auto-generated when the agent’s information is configured in the system.
- emailstring
Email address of the agent specified when the agent information is created in the Freshworks product system.
- avatarobject
Details of the image used as the avatar in the agent profile.
- phonestring
Phone number of the agent.
- biographystring
Description of the agent.
- first_namestring
First name of the agent.
- last_namestring
Last name of the agent.
- role_idinteger
Identifier of the role assigned to the agent.
Roles can be created with different scopes, which define access and permissions according to the organization's requirements.
- role_namestring
Name of the role assigned to the agent.
Roles can be created with different scopes, which define access and permissions according to the organization's requirements.
- social_profilesobject
Information pertaining to the social profiles associated with the agent.
Inbox page
An app deployed on the Inbox page can use the client.data.get(<objectName>) data method and retrieve the following objects:
user
Use the sample code shown on the right pane > Sample code tab, to retrieve information about the user who is a part of the conversation.
Attributes of the user object
- idstring
Identifier of the user.
- emailstring
Email address of the user.
- avatarobject
Details of the image used as the avatar in the user profile.
- phonestring
Phone number of the user.
- propertiesobject
Key-value pairs containing names and values of the custom user properties.
- reference_idstring
External ID used to restore logged-in users.
- created_timestring
Timestamp in UTC format, YYYY-MM-DDTHH:MM:SSZ.
- first_namestring
First name of the user.
- last_namestring
Last name of the user.
- social_profilesobject
Information pertaining to the social profiles associated with the user.
conversation
Use the sample code shown on the right pane > Sample code tab, to retrieve information about the conversation.
Attributes of the conversation object
- conversation_idstring
Identifier of the conversation.
- conversation_urlstring
URL of the conversation.
- app_idstring
Identifier of the Freshchat account.
- idstring
Numerical identifier of the conversation.
- statusstring
Conversation status value.
- assigned_agent_idstring
Identifier of the assigned agent.
- assigned_group_idstring
Identifier of the assigned group.
- messagesarray of objects
Information pertaining to the message.
- agentsobject
Information pertaining to the agent involved in the conversation.
- usersobject
Information pertaining to the user involved in the conversation.
emailConfig
Use the sample code shown on the right pane > Sample code tab, to retrieve a list of email configurations for the email editor in the email conversation inbox of the Freshchat UI.
Attributes of the emailConfig object
- assignToGroupIdinteger
Identifier of the group to which the email conversations are assigned.
The emails sent to the support email can be set for forwarding to create email conversations in the Freshchat inbox page.
- forwardingEmailstring
Email address to which the support emails are forwarded.
- idstring
Identifier of the emailConfig object, auto-generated when an email conversation is initiated in the Freshchat system.
- replyEmailstring
Email address from which the reply email is to be sent.
- senderNamestring
Sender name defined while setting up a support email for forwarding.
- topicIdinteger
Identifer of the topic that the email conversation is categorized under.
Topics can be set up to categorize different issues based on which conversations can be assigned to the relevant group/agent.