Messages

Messages

You can use the API to get the message information.

The Message model

Key

Type

Description

id

String

The unique identifier for the message which is given by Tiledesk.

sender

String

A unique identifier of the sender. It can be: the user identifier, a bot identifier or the system user

senderFullname

String

The sender fullname. It can be: the user fullname, the bot name or an alias

recipient

String

A unique identifier of the recipient. It can be: the request_id field (external id) of the request

status

Number

The message status: FAILED : -100, SENDING : 0, SENT : 100, DELIVERED : 150, RECEIVED : 200, RETURN_RECEIPT: 250, SEEN : 300

text

String

The message text.

type

String

The message type. Accepted values: text (default), image

metadata

Object

The message metadata.

attributes

Object

The custom attributes which are set for the message.

createdAt

String

The time (ISO-8601 date string) when the message was created.

updatedAt

String

The time (ISO-8601 date string) when the message was updated.

createdBy

String

The unique identifier of the row creator

id_project

String

The unique identifier of the project

get
Get the messages of a request by id

https://api.tiledesk.com/v2/:project_id/requests/:id/messages
Fetches the messages by his or her request_id
Request
Response
Request
Path Parameters
id
required
string
the request_id field. It's the external request identifier.
project_id
required
string
the Project Id is a unique code assigned to your project when you create it in Tiledesk.
Headers
Authorization
required
string
authorization token. Basic Auth or JWT
Response
200: OK
[
{
"_id":"5c81593adf767b0017d1aa68",
"updatedAt":"2019-03-07T17:47:38.411Z",
"createdAt":"2019-03-07T17:47:38.411Z",
"sender":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"senderFullname":"Guest",
"recipient":"support-group-L_OG76RYhR0XFiMf2PK",
"text":"test56",
"id_project":"5b55e806c93dde00143163dd",
"createdBy":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"__v":0,
"status":200
},
{
"_id":"5c81593adf767b0017d1aa69",
"updatedAt":"2019-03-07T17:47:38.625Z",
"createdAt":"2019-03-07T17:47:38.625Z",
"sender":"system",
"senderFullname":"Bot",
"recipient":"support-group-L_OG76RYhR0XFiMf2PK",
"text":"La stiamo mettendo in contatto con un operatore. Attenda...",
"id_project":"5b55e806c93dde00143163dd",
"createdBy":"system",
"__v":0,
"status":200
},
...
]

Example:

curl -v -X GET -u andrea.leo@f21.it:123456 https://api.tiledesk.com/v2/5b55e806c93dde00143163dd/requests/support-group-L_OG76RYhR0XFiMf2PK/messages

get
Get the message by request id and message id

https://api.tiledesk.com/v2/:project_id/requests/:id/messages/:message_id
Fetche the message by his or her id
Request
Response
Request
Path Parameters
id
required
string
the request_id field. It's the external request identifier.
message_id
required
string
the message identifier
project_id
required
string
the Project Id is a unique code assigned to your project when you create it in Tiledesk.
Headers
Authorization
required
string
authorization token. Basic Auth or JWT
Response
200: OK
{
"_id":"5c81593adf767b0017d1aa68",
"updatedAt":"2019-03-07T17:47:38.411Z",
"createdAt":"2019-03-07T17:47:38.411Z",
"sender":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"senderFullname":"Guest",
"recipient":"support-group-L_OG76RYhR0XFiMf2PK",
"text":"test56",
"id_project":"5b55e806c93dde00143163dd",
"createdBy":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"__v":0,
"status":200
}

Example:

curl -v -X GET -u andrea.leo@f21.it:123456 https://api.tiledesk.com/v2/5b55e806c93dde00143163dd/requests/support-group-L_OG76RYhR0XFiMf2PK/messages/5c81593adf767b0017d1aa68

post
Send a message.

https://api.tiledesk.com/v2/:project_id/requests/:id/messages
Allows to send a message.
Request
Response
Request
Path Parameters
project_id
required
string
The project_id is a unique code assigned to your project when you create it in Tiledesk
request_id
required
string
The request identifier. Must follow this pattern 'support-group-UUID'
Headers
Authorization
required
string
authorization token. Basic Auth or JWT
Content-Type
required
string
use "application/json" value
Body Parameters
text
required
string
the message text
departmentid
optional
string
The selected department identifier. Accepted only on the first message.
sourcePage
optional
string
The source page of the request. Accepted only on the first message.
language
optional
string
The language of the request. Accepted only on the first message.
userAgent
optional
string
The userAgent string of the request. Accepted only on the first message.
attributes
optional
object
it's the message custom attributes. Example: attributes = {"custom_attribute1": "value1"}.
type
optional
string
it's the message type. "text" value for textual message and "image" for sending image message(you must set metadata field). Available values: text (default) and image.
metadata
optional
object
it's the image properties: src is the absolute source path of the image, width is the image width, height is the image height. Example: metadata = { "src": "https://www.tiledesk.com/wp-content/uploads/2018/03/tiledesk-logo.png", "width": 200, "height": 200 }
Response
200: OK
{
"_id":"5c81593adf767b0017d1aa68",
"updatedAt":"2019-03-07T17:47:38.411Z",
"createdAt":"2019-03-07T17:47:38.411Z",
"sender":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"senderFullname":"Guest",
"recipient":"support-group-L_OG76RYhR0XFiMf2PK",
"text":"hello from api",
"id_project":"5b55e806c93dde00143163dd",
"createdBy":"SRbb2PfbSFcgICv9VQBcURZeloh1",
"__v":0,
"status":200
}

Example:

curl -v -X POST -H 'Content-Type: application/json' -u andrea.leo@f21.it:123456 -d '{"text":"hello from api"}' https://api.tiledesk.com/v2/5b55e806c93dde00143163dd/requests/support-group-1234/messages

Advanced features

Tiledesk uses Chat21 as messaging engine. When you send a message to Tiledesk using the REST API, Tiledesk will forward the call to the Chat21 REST API. You can see how the Chat21 REST Api works here: https://github.com/chat21/chat21-cloud-functions/blob/master/docs/api.md#send-a-message

You can enable special message features following this paragraph: https://github.com/chat21/chat21-cloud-functions/blob/master/docs/api.md#message-attributes