Data Method

You can use these methods to retrieve information about different objects on a page.

Global Data Methods

The loggedInAgent object can be used in all locations and retrieved using data methods.

loggedInAgent - Returns information of a logged in agent.

Copied Copy
1
2
3
4
5
6
7
8
9
client.data.get("loggedInAgent").then ( function(data) { // success operation // "data" is {loggedInAgent: {‘available’: “true”, ... }} }, function(error) { // failure operation } );

Sample Payload

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{ "loggedInAgent" : { "id": "2681d294-3460-4f32-b5fb-828958995b5c", "email": "rachel.john@freshworks.com", "avatar": { "url": "https://web.freshchat.com/img/racheljohn.png" }, "phone": "123456789", "biography": "I am your friendly neighbourhood support!", "first_name": "Rachel", "last_name": "John", "social_profiles": [ { "type": "facebook", "id": "rachel.john" } ] } }
EXPAND ↓

The following table lists the attributes of the loggedInAgent object.

ATTRIBUTE TYPE DESCRIPTION
id string ID of the agent.
email string Email address of the agent.
avatar object Avatar of the agent.
phone string Phone number of the agent.
biography string Job description of the agent.
first_name string First name of the agent.
last_name string Last name of the agent.
social_profiles object Social profiles of the agent.

The attribute of the avatar object is given in the table.
ATTRIBUTE TYPE DESCRIPTION
url string Avatar url.

The attributes of the social profiles’ object are listed in the following table.

ATTRIBUTE TYPE DESCRIPTION
type string Allowed values are Facebook, Twitter, Skype, and Linkedin.
id string Social profile ID of the agent.
Inbox Page Methods

The following objects can be retrieved using data methods:

user - Returns details of a user.

Copied Copy
1
2
3
4
5
6
7
8
9
client.data.get("user").then ( function(data) { // success output // data: {user: {"id": "2681d294-3460-4f32-b5fb-828958995b5c", ...}} }, function(error) { // failure operation } );

Sample Payload

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{ "id": "2681d294-3460-4f32-b5fb-828958995b5c", "email": "rachel.john@freshworks.com", "avatar": { "url": "https://web.freshchat.com/img/racheljohn.png" }, "phone": "123456789", "properties": [ { "name": "orderId", "value": "#1242" } ], "reference_id": "9d83ebc5-e036-4b48-b655-b0d79584b2c6", "created_time": "2018-08-16T11:34:04.431Z", "first_name": "Rachel", "last_name": "John", "social_profiles": [ { "type": "facebook", "id": "rachel.john" } ] }
EXPAND ↓

The following table lists the attributes of the user object.

ATTRIBUTE TYPE DESCRIPTION
id string ID of the user.
email string Email address of the user.
avatar object Avatar of the user.
properties object Key value pairs containing names and values of the custom user properties.
reference_id string External ID used to restore logged in users.
created_time string Timestamp in UTC format, YYYY-MM-DDTHH:MM:SSZ.
phone string Phone number of the user.
first_name string First name of the user.
last_name string Last name of the user.
social_profiles string Social profiles of the user.


The attribute of the avatar object is given in the table.
ATTRIBUTE TYPE DESCRIPTION
url string Avatar url.

The attributes of the social profiles’ object are listed in the following table.

ATTRIBUTE TYPE DESCRIPTION
type string Allowed values are Facebook, Twitter, Skype, and Linkedin.
id string Social profile ID of the agent.

conversation - Returns the conversation details.

Copied Copy
1
2
3
4
5
6
7
8
9
client.data.get("conversation").then ( function(data) { //Success output //data: {conversation: {“conversation_id": “c2937604-0a08-43c2-a09c-e77f5f565a0e”, ...}} }, function(error) { // failure operation } );

Sample Payload

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{ "conversation_id": "c2937604-0a08-43c2-a09c-e77f5f565a0e", "conversation_url": "https://web.freshchat.com/a/14xxxxxxxxx81/inbox/1/0/conversation/21xxxxxxxxxxx83", "app_id": "9d83ebc5-e036-4b48-b655-b0d79584b2c5", "status": "new", "assigned_agent_id": "c2937604-0a08-43c2-a09c-e77f5f565a0e", "assigned_group_id": "c2937604-0a08-43c2-a09c-e77f5f565a0e", "messages": [ { "message_parts": [ { "text": { "content": "string" }, "image": { "url": "string" }, "url_button": { "url": "string", "label": "string", "target": "_self" }, "quick_reply_button": { "custom_reply_text": "string", "label": "string" }, "collection": { "sub_parts": [ null ] } } ], "app_id": "d01f83a4-6af0-4a05-6754-47284db2e1a8", "actor_id": "9d304e8a-31fd-4e4a-85e8-b62edb95d53f", "id": "6c03caf2-a37f-45a2-a9a3-6e03aa7b85f5", "channel_id": "1b99afe4-7b3d-4f9e-b284-d7778b249f6e", "conversation_id": "da8de71b-78c8-4256-8923-0de858ff6a80", "message_type": "normal", "actor_type": "agent", "created_time": "2017-11-16T11:34:04.431Z" } ], "agents": [ { "id": "2681d294-3460-4f32-b5fb-828958995b5c", "email": "govind.patel@freshworks.com", "avatar": { "url": "https://web.freshchat.com/img/johndoe.png" }, "phone": "123456789", "biography": "I am your friendly neighbourhood support guy!", "first_name": "Govind", "last_name": "Patel", "social_profiles": [ { "type": "facebook", "id": "govind.patel" } ] } ], "users": [ { "id": "2681d294-3460-4f32-b5fb-828958995b5c", "email": "govind.patel@freshworks.com", "avatar": { "url": "https://web.freshchat.com/img/johndoe.png" }, "phone": "123456789", "properties": [ { "name": "orderId", "value": "#1242" } ], "reference_id": "9d83ebc5-e036-4b48-b655-b0d79584b2c6", "created_time": "2018-08-16T11:34:04.431Z", "first_name": "Govind", "last_name": "Patel", "social_profiles": [ { "type": "facebook", "id": "govind.patel" } ] } ] }
EXPAND ↓

The following table lists the attributes of the conversation object.

ATTRIBUTE TYPE DESCRIPTION
conversation_id string ID of the conversation.
conversation_url string URL of the conversation.
app_id string ID of the Freshchat account.
messages Array of objects Contains information of message objects.
status string Conversation status value.
agents object Contains list of participating agents.
users object Contains user information.
assigned_agent_id string ID of the assigned agent.
assigned_group_id string ID of the assigned group.


The following table lists the attributes of the message object.

ATTRIBUTE TYPE DESCRIPTION
message_parts Array of message_part Encapsulates contents of the message_part.
app_id string ID of the app.
actor_id string ID of the actor.
id string ID of the message.
channel_id string ID of the channel.
conversation_id string ID of the conversation.
message_type string Type of message.
actor_type string Type of actor, user or agent.
created_time string Conversation creation timestamp in UTC format, YYYY-MM-DDTHH:MM:SSZ.


The following table lists the attributes of the message_part object.

ATTRIBUTE TYPE DESCRIPTION
text object Contains the content value.
image object Contains the image URL.
url_button object Contains details of the URL button.
quick_reply_button object Key value pairs containing the custom reply text and label.
collection array of message sub-parts Can contain combinations of text, image, url_button, and quick_reply_button.

Note:
Only one attribute should be present in the message_part object.


The following table lists the attributes of the url_button object.

ATTRIBUTE TYPE DESCRIPTION
url string Contains the URL value.
label string Contains the label value.
target string Enum of only two allowed values: _self and _blank.