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

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

loggedInAgent

Use the sample code shown on the right pane > Sample code tab, to retrieve information of the agent who is logged into the Freshworks product web UI or widget.

Attributes of the loggedInAgent object

  • abilitiesarray of string

    Specifies the permissions provided for the agent.

  • confirmedboolean

    Specifies if the agent uses a confirmed account.

  • emailstring

    Agent’s email id.

  • idstring

    Identifies the logged in agent.

  • languagestring

    Agent’s preferred conversational language.

  • lastCallAtstring

    Time when the agent last received a call, specified in the date-time format.

  • lastSeenAtstring

    Time the agent was last online, specified in the date-time format

  • mobilestring

    Agent’s mobile number.

  • mobileStatusstring

    Agent’s status on the mobile app.

  • namestring

    Agent’s name.

  • phonestring

    Agent’s phone number.

  • ringOnSpeakersboolean

    Specifies if the agent, in the profile settings, has chosen the ring on speakers and headphones option.

    Possible values: true, false

  • sipEnabledboolean

    Specifies if SIP is enabled for the agent.
    The agent’s name is added to the SIP credentials when the SIP phone is configured when sipEnabled is true.

    Possible values: true, false

  • sipStatusboolean

    Specifies if the agent, in the profile settings, has chosen the Receive calls on SIP Phone option.

    Possible values: true, false

  • statusstring

    Status of the agent. An agent can set the status to online or offline. Also, the status can be automatically set to busy (during a call) and acw (after a call).

    Possible values: online, busy, acw, and offline

  • timeZonestring

    Agent’s time zone.

currentCall

Use the sample code shown on the right pane > Sample code tab, to retrieve information of a completed call.

Attributes of the currentCall object

  • idinteger

    Identifier associated with a call.