Skip to content

Chat Sessions

Chat Sessions API

This endpoint exposes chat session database. Through this endpoint you can query counts of arbitrary types of chat sessions of your own organization, and of organizations which have been involved in chat sessions owned by you.

POST https://api.giosg.com/api/reporting/v1/orgs/<organization_id>/chat_sessions

This endpoint returns:

  • 200 if the request was successful
  • 401 if you are not authenticated
  • 403 if you do not have access to the organization
  • 404 if the organization does not exist

Request payload (query definition)

An example request: "Count of unique visitors which initiated a visitor chat session during 1.1.2019 (Helsinki time)."

1
POST https://api.giosg.com/api/reporting/v1/orgs/b0a1d32b-e82c-11e4-b081-6c4008adf7e8/chat_sessions
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
  "interval": {
    "start": "2019-01-01T00:00:00.000+02:00",
    "end": "2019-01-01T23:59:59.999+02:00",
    "time_zone": "Europe/Helsinki"
  },
  "granularity": "all",
  "group_by": [],
  "aggregations": [
    {
      "type": "hyperUnique",
      "fields": ["visitor_ids"]
    }
  ],
  "filters": {
    "type": "and",
    "fields": [
      { "type": "selector", "dimension": "scope", "value": "org" },
      { "type": "selector", "dimension": "chat_type", "value": "visitor" },
      { "type": "selector", "dimension": "chat_initiator", "value": "visitor" }
    ]
  }
}
Attribute Type Description
interval Interval Time interval of the query.
granularity Granularity Granularity of the query.
aggregations [Aggregation, ...] All different aggregations to be calculated in this query.
group_by [[Dimension, ...] All dimensions to be used in grouping the query results. Leave empty if you don't want to group by any dimension.
filters [[Filter, ...] ] Filter for selecting the session rows for the query.

Response payload (query result)

An example response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{
  "fields": [
    {
      "name": "start_time",
      "type": "dimension"
    },
    {
      "name": "visitor_ids_hyper_unique",
      "type": "metric"
    }
  ],
  "data": [["2019-01-01T00:00:00.000+02:00", 51.01]]
}
Attribute Type Description
fields [Field, Field, ...] Field of the result.
data [Datapoint, ...] Values for fields in the same order as in fields array, one Datapoint for each bucket.

Available dimensions

Dimension Description
chat_initiator If the chat session was initiated by autosuggest, this is "autosuggest". If the chat session was initiated by chat message from visitor, this is "visitor", "operator" if from user, and "rule" if from rule.
chat_session_id Unique id of the chat session.
chat_type Whether the chat's type is operator (operator), visitor (visitor), group (group), task (task) or from some external source (external). If the chat session happened between only users, this is operator. If the chat session had at least one visitor, this is visitor. If the chat session was from external source, this is external. External chats can have members of any type.
chatted_organization_ids If scope == "org", this is unique ids of organizations of users who sent chat messages to the chat session. Otherwise, an empty array.
order_count Number of orders in the chat session. If scope == "user" or "team", this is the number of orders of the chat session after the user or team joined the chat session. If scope == "org", this is total number of orders of the chat session.
owner_organization_id Unique id of the room owner organization.
room_ids Unique ids of rooms the chat session happened in.
sales Sum of sales in the chat session. If scope == "user" or "team", this is the sales of the chat session after the user or team joined the chat session. If scope == "org", this is total sales of the chat session.
scope If the row describes chat session of an organization, this is "org". Similar logic applies for values "user" and "team". NB. Generally, each query should contain only rows of one scope. One chat session will produce multiple rows: one for owner organization, one for each chatted team, and one for each chatted user, and mixing those rows makes sense very rarely!
subscription_sales Sum of subscription sales in the chat session. If scope == "user" or "team", this is the subscription sales of the chat session after the user or team joined the chat session. If scope == "org", this is total subscription sales of the chat session.
team_id  If scope == "team", this is the unique id of the team for which the chat session is reported, otherwise null.
user_id  If scope == "user", this is the unique id of the user for which the chat session is reported, otherwise null.
user_message_count This is number of chat messages which have been sent by users of the scope to the chat session. E.g. if scope == "team", this contains only messages from the team.
user_organization_id  If scope == "user", this is the unique id of organization of the user for which the chat session is reported, otherwise null.
visitor_ids Unique ids of all visitors which are members of the chat session.
visitor_message_count Number of chat messages which have been sent by visitors to the chat session.
visitor_session_ids Unique ids of all visitor sessions which are members of the chat session.

Available aggregations

Type Available for dimensions Result type Description
avg "order_count", "user_message_count", "visitor_message_count", "sales", "subscription_sales"  float The average value of a dimension among the included chat sessions.
sum "order_count", "user_message_count", "visitor_message_count", "sales", "subscription_sales"  float The sum of values of a dimension among the included chat sessions.
hyperUnique "chat_session_id", "visitor_ids", "visitor_session_ids" float The cardinality of the dimension's values. Calculated using HyperLogLog algorithm. It introduces a maximum of 2% error in exchange for performance.
count - integer The number of the included chat session rows. This aggregation type does not need fields defined, as it only calculates included rows.