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.
This section,
- 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:
loggedInAgent
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
- 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 Freshchat 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.