Tiledesk Developer Hub
WebsiteCommunityTutorialsGet started
  • Introduction
  • Community
  • Ask for Support
  • Public Roadmap and Changelog
  • Tutorials
  • Widget
    • Widget SDK
    • Javascript API: Methods
    • Javascript API: Attributes
    • Javascript API: Listeners/Events
    • Widget Authentication
    • Widget Angular integration
    • Widget React integration
    • Widget for Android with WebView
    • Widget for iOS with WKWebView
    • Widget for Flutter with WebView
    • Widget for React with WebView
    • Widget for Wix Website platform
    • Tutorials
      • Hide widget
      • Show/Hide widget programmatically
      • Force widget loading without user interaction
      • Mobile positioning
      • Custom size (width/height)
      • Installing widget on selected pages
    • Conversation Embedded Apps
      • Payment App Tutorial
      • Prechat form App Tutorial
    • Advanced
      • Preset the Widget on a specific Department
      • Authentication Flow
      • Widget protocol specs
      • Prechat Form JSON specs
      • Prevent multiple conversations
      • Old versions
        • Web SDK v4
  • External Chatbot
    • Introduction
    • Hello World tutorial
    • Chatbot to Human handoff
    • Send Text Buttons
    • Advanced Tutorials
      • Introduction
      • Tutorial 1 - Dialogflow as external chatbot
      • Tutorial 2 - Buttons and images
      • Tutorial 3 - Automatic human handoff with fallback intent
      • Tutorial 4 - Explicit Human handoff with user intent
      • Tutorial 5 - Gracefully handling operating hours during handoff
      • Generate Dialogflow Google Credentials file
    • Rasa tutorials
      • Rasa Tutorial 1 - Rasa as external chatbot
  • Resolution bot
    • Introduction
    • Quickstart
    • Webhook service
    • Rich messages
    • Tutorials
      • Chatbot chooser (multilanguage)
      • Department chooser
      • Order info (webhook)
  • APIs
    • REST APIs
      • Introduction
      • Authentication
      • Requests
      • Leads
      • Messages
      • Activities
      • Projects
      • Team
      • User
      • Analytics
      • Canned responses
      • Tags
      • Events
      • Jwt
      • Labels
      • Images
      • Files
      • Segments
      • Chatbots
      • Knowledge Bases
        • Knowledge Base
        • Contents
        • Question & Answer
      • Management Api
        • Departments
        • Groups
    • NodeJS SDK
    • Webhooks
      • Subscriptions
    • Conversation Messages APIs tips
    • Realtime API
    • JWT Authentication
      • JWT Custom authentication Tutorial
    • Tutorials
      • REST API
        • Sending and receiving messages with Tiledesk APIs
        • PHP Tiledesk REST API example
        • Import multiple messages into Tiledesk using REST APIs from third party app
      • Webhooks
        • Custom Request assignment
        • Request transcript on close
  • Apps
    • Build Custom App - Quick start
    • External Channels integration flow diagram
    • Telegram integration tutorial
  • Dashboard & AgentChat SDK
    • Dashboard SDK
    • Agent Chat SDK
  • Architecture
    • Architecture overview
    • Components list
    • Bot Design diagram
    • Multi Channel Message Flow
  • Installation
    • Installation
    • Running Tiledesk using Docker Compose
    • Running Tiledesk with Kubernetes using Helm
    • Choosing Hardware
  • Configuration
    • Chat21 channel configuration
    • Email parameters and templates configuration
    • Configure the logging system
Powered by GitBook
On this page
  • Topics
  • Rate Limiting
  • Using The API
  • Allowed For
  • Establish Connection
  • Subscribe to a topic
  • Process Incoming Events
  • Unsubscribe
  • Example

Was this helpful?

  1. APIs

Realtime API

The Realtime API provides programmatic access to ongoing activity in your Tiledesk server.

The Realtime API is implemented using WebSocket technology.

You can use the API to do the following:

  • Display requests data

  • Display agents data

  • Create and display a real-time dashboard

  • Predict or estimate capacity and other derived metrics

The Realtime API allows you to receive events from Tiledesk after you subscribe to one or more topics.

This API is an SSL-only API. You must be a verified user to make API requests. You can authorize against the API using JWT token.

Topics

Topic
Description

/PROJECT_ID/requests

Get the last open requests of a project

/PROJECT_ID/requests/REQUEST_ID

Get the requests detail

/PROJECT_ID/requests/REQUEST_ID/messages

Get the request messages

/PROJECT_ID/project_users/PROJECT_USER_ID

Get the agents info

Rate Limiting

We only allow a certain number of new connections per minute. The number of new connections to the Realtime API is restricted by REST API rate limits. We also allow a certain number of concurrently running connections to the Realtime API.

We reserve the right to adjust the rate limit for given endpoints in order to provide a high quality of service for all clients. If the rate limit is exceeded, Tiledesk will respond with a body that details the reason for the rate limiter kicking in.

We also limit the total amount of data exchanged through real time APIs. For example the number of Realtime requests exchanged can’t exceed a certain number of items. If this number is exeeded you can always use REST APIs to get additional data or to make more complex queries.

Using The API

  • Establish an authenticated WebSocket connection to wss://eu.rtmv3.tiledesk.com/api/.

  • Subscribe to one or several topics.

  • Process incoming events.

  • Unsubscribe to topics.

Allowed For

  • Owner

  • Administrator

  • Agent

Establish Connection

Connect to the wss://eu.rtmv3.tiledesk.com/api/ WebSocket endpoint using your JWT token.

  var ws = new WebSocket("wss://eu.rtmv3.tiledesk.com/api/?token=YOUR_JWT_TOKEN"); 

  ws.onopen = function () {
      console.log('websocket is connected.');         
  }

  ws.onclose = function () {
      console.log('websocket is closed.');           
  }

  ws.onerror = function () {
      console.log('websocket error ...')
  }

Subscribe to a topic

Once connection is established, you can send messages to subscribe to individual topics. Refer to Topics for the topic key.

{
   "action":"subscribe",
   "payload":{
      "topic":"/<YOUR_PROJECT_ID_HERE>/requests"
   }
}

To subscribe to a topic you can execute :

ws.send(JSON.stringify(subscriptionMessage));

Example:

var subscriptionMessage =
{
   "action":"subscribe",
   "payload":{
      "topic":"/5df26badde7e1c001743b63c/requests"
   }
}

ws.send(JSON.stringify(subscriptionMessage));

Process Incoming Events

Once you have subscribed to one or several topics, listen to subsequent messages to start collecting data.

 ws.onmessage = function(message) {   
    console.log(message);
    try {
         var data = JSON.parse(message.data);
    } catch (e) {
       return console.log('This doesn\'t look like a valid JSON: ', message.data);
    }

   //.... ADD YOUR LOGIC HERE    
}

The following are sample messages received after subscribing to requests topic:

{
   "action":"publish",
   "payload":{
      "topic":"/5eb45fbc1f9e1f0012d62207/requests",
      "method":"CREATE",
      "message":[
         {
            "_id":"5eb4fc911f9e1f0012d62248",
            "status":200,
            "preflight":false,
            "participants":[
               "5eb45fb21f9e1f0012d62201"
            ],
            "request_id":"support-group-1a952f2f-c09a-46be-bc75-11387a95d55f",
            "requester":"5eb45fbc1f9e1f0012d62208",
            "lead":{
               ...
            },
            "first_text":"hello world",
            "department":"5eb45fbc1f9e1f0012d62209",
            ...
            "assigned_at":"2020-05-08T06:30:41.090Z",
            "id_project":"5eb45fbc1f9e1f0012d62207",
            "createdBy":"5eb45fb21f9e1f0012d62201",
            "tags":[

            ],
            "notes":[

            ],
            "channel":{
               "name":"chat21"
            },
            "createdAt":"2020-05-08T06:30:41.094Z",
            "updatedAt":"2020-05-08T06:31:00.367Z",
            "__v":0,
            "first_response_at":"2020-05-08T06:30:58.109Z",
            "waiting_time":17015,
            "id":"5eb4fc911f9e1f0012d62248",
            ....
         },
         ..
      ]
   }
}

Unsubscribe

Once you stop processing some data, you can individually unsubscribe from a topic. Events will then stop being pushed on the connection.

{
   "action":"unsubscribe",
   "payload":{
      "topic":"/<YOUR_PROJECT_ID_HERE>/requests"
   }
}

Example

PreviousConversation Messages APIs tipsNextJWT Authentication

Last updated 11 months ago

Was this helpful?

You can find a simple example of the Tiledesk Realtime API

here