Manual API Chat2desk
Manual API Chat2desk
Manual API Chat2desk
07
Consultora Especializada
Contenido
Contenido.....................................................................................................1
API Manual...................................................................................................2
API Version 1.07...........................................................................................2
Terms...........................................................................................................2
General information.....................................................................................2
Before you begin..........................................................................................3
List of API commands...................................................................................4
messages (GET)...........................................................................................5
web_hook (POST).........................................................................................7
messages (POST).........................................................................................8
messages/inbox (POST).............................................................................10
messages/assign (POST)............................................................................11
api_info (GET).............................................................................................12
clients (GET)...............................................................................................13
clients (POST).............................................................................................16
clients (PUT)...............................................................................................17
operators (GET)..........................................................................................17
dialogs (GET)..............................................................................................18
dialogs (PUT)..............................................................................................20
roles (GET).................................................................................................21
dialog_states (GET)....................................................................................21
channels (GET)...........................................................................................22
regions (GET).............................................................................................23
countries (GET)..........................................................................................23
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 1 de 28
www.FiveTek.com.mx
c
transports (GET).........................................................................................24
messages/read (GET).................................................................................25
api_modes (GET)........................................................................................25
Confidencialidad........................................................................................26
Firmas de Aceptacin.................................................................................27
API Manual
API Version 1.07
This API is designed to work with Chat Helpdesk service.
Terms
A client is a person, who contacts your company via service Chat Helpdesk
using messengers and SMS.
A channel is an account (phone number or id) in messengers WhatsApp,
Viber, Telegram, Facebook, VKontakte, Live Chat or SMS or external
channel, used by your company to chat with clients via service Chat
Helpdesk.
An external channel is a channel, which is not directly connected to the
Chat Helpdesk service, for example, live chat, your own messenger or your
own bot. Such external channel can be connected to the service using this API.
A transport is a messenger or SMS, using which, messages are being
received or sent via given channel.
General information
1. To test and set up this API, we recommend to use Postman app for Google Chrome. Heres a
link to access a collection of preset API commands for Chat Helpdesk using test account
(import it in Postman): https://www.getpostman.com/collections/c598e71f85fd72404ff6
2. RESTful architecture and methods GET, PUT and POST are used.
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 2 de 28
www.FiveTek.com.mx
c
5. Authorisation is based on <token>, which is available in API settings. Here are the parameters
for all commands:
Authorization: <token>
Host: api.chat2desk.com
6. Commands that return big list of data support pagination using URL parameters:
b. offset offset from the 1st record of the list (default is 0).
Handling a new message event with web_hook (POST). This method is more preferred.
a. Your clients use messengers channel to connect to the system. In this case operate messages
(GET) or web_hook (POST). To send - use clients (POST) and messages (POST).
b. Your clients use external channel (see Terms). In this case you should operate
messages/inbox (POST) to transfer messages from your client to the system.
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 3 de 28
www.FiveTek.com.mx
c
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 4 de 28
www.FiveTek.com.mx
c
clients (PUT)
Assigns a name to a client.
channels (GET)
Returns a list of your channels with info.
regions (GET)
Returns a list of available regions.
countries (GET)
Returns a list of available countries.
transports (GET)
Returns a list of available transports and their supported attachments.
messages/read (GET) Tags a message as read.
api_modes (GET)
Returns a list of available API access levels.
questions/<id>/send (GET)
Sends specified menu item to the client when using scripts (see Help >
Scripts
manual).
clients/<id>/questions (GET)
Returns a list of menu items that were sent to a client during specified date
span (optionally) when using scripts (see Help > Scripts manual).
Request:
messages (GET)
Returns a list of accumulated messages (both from and to clients). If Viber
Business transport is used, delivery status is returned.
Request:
GET /v1/messages or
GET /v1/messages/<id>
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 5 de 28
www.FiveTek.com.mx
c
Parameters:
<id> message id.
type
dialog_id
read
GET /v1/messages?
transport=telegram&type=from_client&read=false
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 6 de 28
www.FiveTek.com.mx
c
"id": 614,
"text": "Hi. See the photo.",
"photo": "http://chat2desk.com/images/users/
message/_19-45-03.jpg",
"coordinates": null,
"transport": "whatsapp",
"type": "from_client",
"read": true,
"created": "2016-01-11T19:45:05 UTC",
"client_id": 13,
"vb_bus_id":
"597110513645559990912348615203629047737",
"recipient_status": "delivered",
}
],
"meta": {
"total": 617,
"limit": 20,
"offset": 610
},
"status": "success"
}
Typical reply when requesting one message, using its <id>:
{
"id": 614,
"text": " Hi. See the photo.", "photo":
"http://chat2desk.com/images/users/
message/_19-45-03.jpg", "coordinates": null,
"transport": "whatsapp",
"type": "from_client",
"read": true,
"created": "2016-01-11T19:45:05 UTC",
"client_id": 13,
"dialog_id": 11,
"operator_id": 1,
"channel_id": 1
},
"status": "success"
}
Some fields:
coordinates geo coordinates.
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 7 de 28
www.FiveTek.com.mx
c
type:
read read by operator tag of a message from client. All messages to client are considered
as read except Viber Business transport.
recipient_status info about delivery status of the message (now applies only to Viber
Business transport).
web_hook (POST)
Web_hook is used for two purposes:
1. To monitor incoming messages from your client to the system when using messengers
(regular channel).
2. To monitor outgoing messages from the system (operator) to the client when using external
channel.
Request:
POST /v1/companies/web_hook
Request body:
{
"url": "https://google.com"
}
Any URL is allowed but we recommend https. If empty value (null) is set then
web hook is deleted. You can check your current web hook with api_info
(GET).
In case incoming message from a client is received, web hook returns an info as does
messages (GET), and type equals from_client.
In case of outgoing message from the system to a client, a reply contains message data,
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 8 de 28
www.FiveTek.com.mx
c
clients id, operators name and more see messages/inbox (POST), and type equals
from_system.
messages (POST)
Sends a message to a client. You can refer a client only by id. So this client
should exist in your client list. Otherwise, use clients (POST).
Request:
POST /v1/messages
Request body:
{
"client_id": 7,
"text": "Hi there!",
"attachment": "
http://chat2desk.com/images/tg_app_en.jpg",
"type": "to_client",
"transport": "viber",
"channel_id": 1,
"operator_id": 3
}
Params:
client_id client id (see clients (GET)).
attachment URL for attachment (photo, video, audio). Sending coordinates to a client is not
supported. Check transports (GET) about supported attachments for given transport.
type:
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 9 de 28
www.FiveTek.com.mx
c
channel_id see channels (GET). If omitted, channel of last message from the client will be
used.
operator_id see clients (PUT). Set type autoreply and dont specify operator_id to
avoid assigning new operator to a dialog.
Assigns a name to a client (assigned name). This name can contain real clients
name or extended info (for example, VIP status).
Request:
PUT /v1/clients/<id>
Request body:
{
"nickname": "This is real VIP
client!" }
Typical reply contains info about actually used channel, operator and more:
"data": {
"channel_id": 1,
"operator_id": 3,
"transport": "whatsapp",
"type": "to_client",
"client_id": 7
},
"status": "success" }
messages/inbox (POST)
Sends incoming message from client to the system using external channel.
Request:
POST /v1/messages/inbox
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 10 de 28
www.FiveTek.com.mx
c
Request body:
{
"channel_id": "1", "body":
"This is message text",
"image": <url>,
"video": <url>,
"location": "lat lng"
"from_client": {
"id": 123abc, or "phone": 19110001122,
"nickname": "API_boy"
}
}
Some parameters:
id id as you identify a client (any symbols), except phone
number.
If you identify a client with phone number, then use the next parameter.
messages/assign (POST)
Assigns new message to an operator specified. The message should not belong
to open dialog (i.e. should be a message from new client or from old client but
in closed dialog). This command, actually, assigns an operator to perform a
chat with given client.
Request:
POST /v1/messages/<id>/assign
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 11 de 28
www.FiveTek.com.mx
c
Request body:
{
"operator_id": 3
}
Params:
Assigns a name to a client (assigned name). This name can contain real clients
name or extended info (for example, VIP status).
Request:
PUT /v1/clients/<id>
Request body:
{
"nickname": "This is real VIP client!"
}
api_info (GET)
Returns:
Current API version, used by our service.
Request:
GET /v1/companies/api_info
Host: api.chat2desk.com
Authorization: <token>
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 12 de 28
www.FiveTek.com.mx
c
Params:
<token> here and everywhere see description of authorisation.
Typical reply:
{
"data": {
"mode": "demo",
"hook": null,
"current_version": 1,
"requests_this_month": 98,
"channels": 2,
"company_name": "Test company"
},
"status": "success"
clients (GET)
Returns a list of your clients with their info.
Request:
GET /v1/clients
or
GET /v1/clients/<id>
or
GET /v1/clients/<id>/transport
or
GET /v1/clients?phone=79310001122
or
GET /v1/clients/<id>/last_question
or
GET /v1/clients/<id>/dialogs
Params:
<id> clients id.
If transport key is specified, then the list of available transports for the client specified is
returned.
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 13 de 28
www.FiveTek.com.mx
c
If last_question key is specified, then the last menu item sent to the client is returned.
If dialogs key is specified, then the list of the clients dialogs is returned.
"data": [
{
"id": 1607,
"comment": "This is a comment",
"assigned_name": "Real VIP client",
"phone": "19001112233",
"name": "Thats my name!",
"avatar": "http://chat2desk.com/images/users/client/
1112233_1.jpg",
"region_id": null,
"country_id": 1
},
],
"meta": {
"total": 3911,
"limit": 20,
"offset": 1600
},
"status": "success"
}
Typical reply when client id is specified (one client with extended info):
{
"data": {
"id": 1607,
"comment": "This is a comment",
"assigned_name": "Real VIP client",
"phone": "19001112233",
"name": "Thats my name!",
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 14 de 28
www.FiveTek.com.mx
c
"avatar": "http://chat2desk.com/images/users/client/
11112233_1.jpg",
"region_id": null,
"country_id": 1
"first_client_message": "2015-12-27T18:36:41 UTC",
"last_client_message": "2016-01-28T20:29:25 UTC"
},
"status": "success"
}
Some fields:
See below a typical reply when specifying client id and transport key.
Actually, these are the transports (with channels), which given client used to
chat with your chat center and which can be used to answer to that client.
"data": [
{
"channel_id": 1,
"transports": [
"sms",
"whatsapp"
]
},
{
"channel_id": 2,
"transports": [
"viber"
]
}
],
"status": "success"
}
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 15 de 28
www.FiveTek.com.mx
c
See below a typical reply when specifying client id and last_question key.
This request returns last menu item that was sent to this client earlier.
{
"data": {
"id": 4322,
"text": "This is menu item #20",
"image": null
},
"status": "success" }
clients (POST)
Creates a new client to be able to send a message to him or her. This might be
useful, for example, to send WhatsApp notifications to your clients who never
contacted you via WhatsApp before.
Use with caution because a client that you contact first, likely, doesn't have
your number in address book and can tap This is spam! button, which may
lead your WhatsApp or Viber account to get blocked.
Request:
POST /v1/clients?
phone=19310001122&transport=whatsapp&channel_id=1
Params:
phone clients phone number with country code, without any symbols and spaces.
transport name of a transport (messenger), via which you want to contact this client. You
can create a new client only using WhatsApp, Viber and SMS. To get a list of available
transports use transports (GET).
Channel_id (optional) id of a channel in which the client will be created. If left blank, your
first channel will be used. To get a list of your channels use channels (GET).
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 16 de 28
www.FiveTek.com.mx
c
"data": {
"id": 75,
"assigned_name": null,
"phone": "11111111113",
"name": null,
"avatar": null,
"region_id": null,
"country_id": 1,
"first_client_message": "2016-07-07T05:34:28 UTC",
"last_client_message": "2016-07-07T05:34:28 UTC"
},
"status": "success"
}
Having received the clients id, you can now send this client a message.
The option to create a new client to message him or her afterwards is turned off
by default. In this case the command will return an error. Contact
administration to turn this option on for you.
clients (PUT)
Assigns a name to a client (assigned name). This name can contain real clients
name or extended info (for example, VIP status).
Request:
PUT /v1/clients/<id>
Request body:
{
"nickname": "This is real VIP
client!" }
Params:
<id> client id.
nickname client name (assigned name). If null is specified, then the name will be deleted.
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 17 de 28
www.FiveTek.com.mx
c
operators (GET)
Returns a list of your operators.
Request:
GET /v1/operators
online
Typical reply:
{
"data": [
{
"id": 1,
"email": "[email protected]",
"phone": null,
"role": "admin",
"online": false,
"offline_type": null,
"first_name": null,
"last_name": null, "last_visit":
"2016-03-11T19:45:22 UTC"
},
{
"id": 2,
"email": "[email protected]",
"phone": "15550001122",
"role": "supervisor",
"online": false,
"first_name": "John",
"last_name": "Smith", "last_visit": "2016-02-
25T17:25:43 UTC"
}
],
"meta": {
"total": 2,
"limit": 20,
"offset": 0
},
"status": "success" }
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 18 de 28
www.FiveTek.com.mx
c
dialogs (GET)
Returns a list of your dialogs. Once an operator opens a chat with a client, the
messages start to belong to a dialog.
Request:
GET /v1/dialogs
or
GET /v1/dialogs/<id>
Params:
<id> dialog id (optionally). If specified, only info about given dialog will be returned.
state
GET /v1/dialogs?operator_id=2
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 19 de 28
www.FiveTek.com.mx
c
"id": 3,
"state": "open", "begin": "2015-07-24T11:30:32
UTC",
"end": null,
"operator_id": 1
},
],
"meta": {
"total": 429,
"limit": 20,
"offset": 0
},
"status": "success"
}
Some fields:
o The dialog is manually closed by an operator on the web site or with dialogs (PUT).
dialogs (PUT)
Changes a dialog state to open or closed and sets up its operator.
Request:
PUT /v1/dialogs/<id>
Params:
<id>
dialog id (required). See dialogs (GET).
Request body:
{
"operator_id": 1, "state": "open" or "closed",
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 20 de 28
www.FiveTek.com.mx
c
roles (GET)
Returns a list of available roles.
Request:
GET /v1/help/roles
Typical reply:
{
"data": [
"unconfirmed",
"operator",
"supervisor",
"admin",
"disabled",
"deleted"
],
"status": "success"
dialog_states (GET)
Returns a list of available dialog states.
Request:
GET /v1/help/dialog_states
Typical reply:
{
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 21 de 28
www.FiveTek.com.mx
c
"data": [
"open",
"closed"
],
"status": "success"
channels (GET)
Returns a list of your channels with info.
Request:
GET /v1/channels
GET /v1/channels?phone=172502619555
Typical reply:
{
"data": [
{
"id": 1,
"name": "Demo", "phone": "79217639603"
},
{
"id": 2,
"name": "Viber only",
"phone": "79006323538"
},
{
"id": 3,
"name": "Free",
"phone": "79006538466"
},
{
"id": 4,
"name": "Boston",
"phone": "172502619555"
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 22 de 28
www.FiveTek.com.mx
c
}
],
"meta": {
"total": 4,
"limit": 20,
"offset": 0
},
"status": "success"
}
regions (GET)
Returns a list of available regions. This list is used for automatic region
detection based on clients mobile phone. A list of countries also available
see countries (GET).
Request:
GET /v1/regions
Typical reply:
{
"data": [
{
"id": 1,
"country": "",
"region": ""
},
{
"id": 2,
"country": "",
"region": ""
},
{
"id": 3,
"country": "",
"region": ""
},
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 23 de 28
www.FiveTek.com.mx
c
countries (GET)
Returns a list of available countries.
Request:
GET /v1/countries
Typical reply:
{
"data": [
{
"id": 1,
"name": "USA, Canada"
},
{
"id": 2,
"name": "Russia"
},
{
"id": 3,
"name": "Egypt"
},
{
"id": 4,
"name": "South Africa"
},
transports (GET)
Returns a list of available transports and their supported attachments.
Request:
GET /v1/help/transports
Typical reply:
{
"data": {
"whatsapp": {
"from_client": {
"text": "yes",
"image": "yes",
"audio": "no",
"pdf": "no",
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 24 de 28
www.FiveTek.com.mx
c
"video": "yes",
"location": "yes"
},
"to_client": {
"text": "yes",
"image": "yes",
"audio": "yes",
"pdf": "yes",
"video": "no",
"location": "yes"
}
},
}
}
},
"status": "success" }
messages/read (GET)
Params:
api_modes (GET)
Returns a list of available API access levels. To check you current access level
see api_info (GET).
Request:
GET /v1/help/api_modes
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 25 de 28
www.FiveTek.com.mx
c
Typical reply:
{
"data": [
{
"name": "disabled",
"description": "API disabled"
},
{
"name": "demo",
"description": "1000 requests per month"
},
{
"name": "normal", "description":
"50000 requests per month"
},
{
"name": "unlimited", "description":
"unlimited requests per month"
}
],
"status": "success"
}
Confidencialidad
El material contenido en este documento es propiedad de Fivetek S.A. de C.V. y es
estrictamente confidencial. Se hace entrega del mismo a El Cliente con el entendimiento
que no ser mostrado, ledo ni distribuido a cualquier persona ajena a dicha compaa y es de
uso exclusivo para evaluar la capacidad de Fivetek en brindar servicios a El Cliente. En
tanto no se realice un contrato formal por los proyectos que del trabajo aqu documentado
puedan surgir entre El Cliente y Fivetek, este material es propiedad de Fivetek y su
contenido no puede ser difundido por El Cliente a una tercera parte, ni ningn
concepto, idea o material original aqu desarrollado podr ser utilizado comercialmente por
El Cliente. La informacin que haya aportado El Cliente acerca de su empresa para la
elaboracin de este documento, ser mantenida bajo estricta confidencialidad en Fivetek.
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 26 de 28
www.FiveTek.com.mx
c
Firmas de Aceptacin
Fivetek Consulting
El Cliente
Project: Chat2Desk
Atencin: www.chat2desk.com.mx Estatus: LIB
Fecha: Febrero 1, 2017 Versin: 1.0
Pgina: 27 de 28
www.FiveTek.com.mx