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 (Freshchat) 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 Freshchat 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.
- Lists all the objects that can be retrieved by using the data method.
- Describes all the attributes of the retrieved object.
Data object 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 object irrespective of where the app is deployed:
Use the sample code shown on the right pane > Sample code tab, to retrieve information on the agent logged into the Freshchat UI.
Attributes of the loggedInAgent object
Identifier of the agent, auto-generated when the agent’s information is configured in the system.
Email address of the agent specified when the agent information is created in the Freshchat system.
Details of the image used as the avatar in the agent profile.
Phone number of the agent.
Description of the agent.
First name of the agent.
Last name of the agent.
Information pertaining to the social profiles associated with the agent.
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
Identifier of the user.
Email address of the user.
Details of the image used as the avatar in the user profile.
Phone number of the user.
Key-value pairs containing names and values of the custom user properties.
External ID used to restore logged-in users.
Timestamp in UTC format, YYYY-MM-DDTHH:MM:SSZ.
First name of the user.
Last name of the user.
Information pertaining to the social profiles associated with the user.
Use the sample code shown on the right pane > Sample code tab, to retrieve information about the conversation.
Attributes of the conversation object
Identifier of the conversation.
URL of the conversation.
Identifier of the Freshchat account.
Conversation status value.
Identifier of the assigned agent.
Identifier of the assigned group.
- messagesarray of objects
Information pertaining to the message.
Information pertaining to the agent involved in the conversation.
Information pertaining to the user involved in the conversation.