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 (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,

  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 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.

  • 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.

  • 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.