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
  • Targets
  • Steps
  • Signup on Tiledesk
  • Anonymous end-user authentication through APIs
  • Creating the conversation (request)
  • Sending messages to a conversation

Was this helpful?

  1. APIs
  2. Tutorials
  3. REST API

Import multiple messages into Tiledesk using REST APIs from third party app

PreviousSending and receiving messages with Tiledesk APIsNextWebhooks

Last updated 1 year ago

Was this helpful?

Targets

This tutorial will help you to understand how to insert multiple messages into Tiledesk using REST API from third party app. Suppose you have an application (ex. a chatbot framework or a customer support system) and you want to connect it with Tiledesk. For example suppose you have a chatbot software that automatically serves the users (via a widget or others channels) but at some point you want to forward the chat to Tiledesk so that the agents ( and no longer the chatbot) serve the request.

Steps

  1. Signup a user on Tiledesk

  2. Anonymous end-user authentication through APIs

  3. Creating the conversation (request)

  4. Sending messages to a conversation

Signup on Tiledesk

To use Tiledesk APIs is mandatory to signup a new user on our beta environment available on

After signup please follow the proposed wizard to create your first Tiledesk project.

Get the PROJECT_ID of the created project under Project Settings menu. We will use this later.

Anonymous end-user authentication through APIs

curl -v -X POST -H 'Content-Type:application/json' \
-d '{"id_project":"5e2c35c8f0dbc10017bb3aac", "firstname":"John"}' \
https://api.tiledesk.com/v3/auth/signinAnonymously

This will reply with the JWT token that we'll use to send our first message:

{
   "success":true,
   "token":"JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.XYZ....",
   "user":{
      "_id":"fc43a0e1-ba85-404e-9a44-bf0050330898",
      "firstname":"John",
      "id":"fc43a0e1-ba85-404e-9a44-bf0050330898",
      "fullName":"John"
   }
}

Creating the conversation (request)

  • YOUR_ADMIN_EMAIL and PASSWORD: use your admin credentials here

  • SENDER: the anonymous user id created with the previous step.

  • FIRST_MESSAGE: this text is used to summarize the conversation subject. Normally this is the first message send by the user requester.

  • PROJECT_ID: your project id

curl -v -X POST -H 'Content-Type:application/json' \
-u YOUR_ADMIN_EMAIL:PASSWORD -d '{"sender":"SENDER", "first_text":"FIRST_MESSAGE"}' \ https://api.tiledesk.com/v3/PROJECT_ID/requests/
curl -v -X POST -H 'Content-Type:application/json' \
-u andrea.leo@email.it:xyz -d '{"sender":"fc43a0e1-ba85-404e-9a44-bf0050330898", "first_text":"How can i restore my password"}' \ https://api.tiledesk.com/v3/5e2c35c8f0dbc10017bb3aac/requests/

You will get a reponse like this:

{
   "_id":"6346cbed38c343d545cf8092",
   "request_id":"support-group-5e2c35c8f0dbc10017bb3aac-8e40526e6dfb4450a572cd4ede01f464",
   ....
}

Now an empty (without message) conversation is created. Pay attention to the request_id field for the next paragraph.

Sending messages to a conversation

  • request_id: the unique request identifier generated by the previous endpoint call

  • the admins credentials

  • An array of messages where:

    • text: is the message text

    • sender is the user indentifier of the user who send the message

    • attributes.clienttimestamp: use this property to force the message timestamp in milliseconds.

curl -v -X POST -H 'Content-Type:application/json' \
 -u YOUR_ADMIN_EMAIL:PASSWORD \
-d '[{"sender":"bb0d809b-b093-419b-8b48-11a192cc3619","text":"How can i restore my password", "attributes":{"clienttimestamp":1665584701710}},{"sender":"chatbot1", "text":"You can find it here https://tiledesk.com", "attributes":{"clienttimestamp":1665584701711}}]'  \
 https://api.tiledesk.com/v3/5e2c35c8f0dbc10017bb3aac/requests/support-group-5e2c35c8f0dbc10017bb3aac-8e40526e6dfb4450a572cd4ede01f464/messages/multi

Looking at the dashboard of your project you will see your conversation in the Requests panel. The requests are updated in real time, so you don't have to manunally update the Requests' page. If you left unchanged all the default settings, the request will be assigned to you (make sure you are "available", looking in the lower right corner of your profile image in the left menu panel).

The agent (you) can now see the same conversation in the agent chat (first option of the menu panel will open the desktop chat).

Do you have feedback on this article? Please send us your feedback writing an email to info@tiledesk.com

In this tutorial we will authenticate end-users through . We will do an anonymous authentication in order to get the id of the user (requester) who will create the conversation (next paragraph).

Now let's use by setting mainly four parameters:

Let us to import the messages. We need the following parameters :

Create a conversation REST API
Insert multiple messages REST API
https://panel.tiledesk.com/v3/dashboard
Anonymous authentication REST API