Queries

Index

1. GET /query

Method: GET

Pathname:

1 2 {{baseUrl}}/api/v1/{{codename}}/query?skip=0&limit=10 {{baseUrl}}/api/v1/{{codename}}/query?skip=0&limit=10&query={"status":"pending"}

Header:

1 2 3 Accept: 'application/json' Content-Type: 'application/json' Authorization: 'Bearer ' + accessToken

Url params:

Parameter

type

Description

Parameter

type

Description

codename

String

Request the Chat-Tonic team.

Query params:

Parameter

type

Description

Parameter

type

Description

skip

String

Default 0.

limit

String

Default and max value 100.

query

Object

Optional value
{“status“:”pending”}

Valid status values: [pending, progress, resolved]

Sort params:

Parameter

type

Description

Parameter

type

Description

createdAt

Number

-1

1

Note: To obtain the messages of the queries look here. You can make an api call with the messageUser and the createdAt of the query message.

 

Response:

Returns queries

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 { "limit": 10, "skip": 0, "objects": [ { "_id": "5d9f4f976bc65120a93a17b0", "app": "59cbf49fd6976e583b5df5d2", "messageUser": { ... }, "message": { ... }, "account": { "_id": "5820d77d24270e7142e2da34" }, "origins": [], "status": "pending", "dates": { "pending": "2019-10-10T00:00:00.000Z" }, "search": "lautaro piacquadio lpiacquadio@mobile-tonic.com +18", "createdAt": "2019-10-10T00:00:00.000Z", "updatedAt": "2019-10-10T00:00:00.000Z" } ] }

2. POST /query

Method: POST

Pathname:

1 {{baseUrl}}/api/v1/{{codename}}/query

Header:

1 2 3 Accept: 'application/json' Content-Type: 'application/json' Authorization: 'Bearer ' + accessToken

Url params:

Parameter

type

Description

Parameter

type

Description

codename

String

Request the Chat-Tonic team.

Request params:

Parameter

type

Description

Parameter

type

Description

messageUser

object

Required value, Chat-Tonic messageUser.

message

object

Required value, Chat-Tonic message.

account

object

Optional value, Chat-Tonic account.

origin

String

Optional value.

extra

object

Optional value.

Body:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 { "messageUser": { "_id": "5d824ee4c43bfe2439e631cb", "firstName": "Lautaro", "lastName": "Piacquadio", "profilePictureURL": "/api/v1/lpiacquadio/telegram/5820d77d24270e7142e2da34/getfile/AgADAQAD4KcxG1ncDwebydyIVUAQ5M79CjAABAEAAwIAA2MAA6MiAQABFgQ", "platform": "telegram", "pausedBot": false, "blocked": false, "profile": { "email": "lpiacquadio@chat-tonic.com" } }, "message": { "receivedAt": "2019-10-10T00:00:00.000Z", "type": "text", "text": "Hi", "category": "query" }, "origin": "demo" }

Response:

Create a new query, return the query

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 { "_id": "5da0a9afb5509127ce79ff67", "app": "59cbf49fd6976e583b5df5d2", "messageUser": { "pausedBot": false, "blocked": false, "_id": "5d824ee4c43bfe2439e631cb", "firstName": "Lautaro", "lastName": "Piacquadio", "profilePictureURL": "/api/v1/lpiacquadio/telegram/5820d77d24270e7142e2da34/getfile/AgADAQAD4KcxG1ncDwebydyIVUAQ5M79CjAABAEAAwIAA2MAA6MiAQABFgQ", "platform": "telegram", "profile": { "email": "lpiacquadio@chat-tonic.com" } }, "message": { "receivedAt": "2019-10-10T00:00:00.000Z", "type": "text", "text": "Hi", "category": "query" }, "origins": [], "status": "pending", "dates": { "pending": "2019-10-11T16:11:27.204Z" }, "search": "lautaro piacquadio lpiacquadio@mobile-tonic.com ", "createdAt": "2019-10-11T00:00:00.000Z", "updatedAt": "2019-10-11T00:00:00.000Z" }

3. PUT /query/take

Method: PUT

Pathname:

1 {{baseUrl}}/api/v1/{{codename}}/query/take/:queryId

Header:

1 2 3 Accept: 'application/json' Content-Type: 'application/json' Authorization: 'Bearer ' + accessToken

Url params:

Parameter

type

Description

Parameter

type

Description

codename

String

Request the Chat-Tonic team.

queryId

String

Query ID

Response:

Take the query and mark it as in progress for you.

1 2 3 4 5 6 7 8 9 10 11 12 { "ok": true, "query": "5da0a9afb5509127ce79ff67", "operator": { "_id": "59db8ee6127acf48c5c737b4", "displayName": "Me Operator", "name": { "familyName": "Operator", "givenName": "Me" } } }

4. PUT /query/assign

Method: PUT

Pathname:

1 {{baseUrl}}/api/v1/{{codename}}/query/assign/:queryId/to/:userId

Header:

1 2 3 Accept: 'application/json' Content-Type: 'application/json' Authorization: 'Bearer ' + accessToken

Url params:

Parameter

type

Description

Parameter

type

Description

codename

String

Request the Chat-Tonic team.

queryId

String

Query ID

userId

String

Operator ID

Response:

Assign the query to the operator and mark it as in progress.

1 2 3 4 5 6 7 8 9 10 11 12 { "ok": true, "query": "5da0a9afb5509127ce79ff67", "operator": { "_id": "59db8ee6127acf48c5c737b4", "displayName": "Other Operator", "name": { "familyName": "Operator", "givenName": "Other" } } }

5. PUT /query/resolve

Method: PUT

Pathname:

1 {{baseUrl}}/api/v1/{{codename}}/query/resolve/:queryId

Header:

1 2 3 Accept: 'application/json' Content-Type: 'application/json' Authorization: 'Bearer ' + accessToken

Url params:

Parameter

type

Description

Parameter

type

Description

codename

String

Request the Chat-Tonic team.

queryId

String

Query ID

Response:

Mark the query as resolved.

1 2 3 4 { "ok": true, "query": "5da0a9afb5509127ce79ff67" }