Queries
Index
1. GET /query
Method: GET
Pathname:
{{baseUrl}}/api/v1/{{codename}}/query?skip=0&limit=10
{{baseUrl}}/api/v1/{{codename}}/query?skip=0&limit=10&query={"status":"pending"}
Header:
Accept: 'application/json'
Content-Type: 'application/json'
Authorization: 'Bearer ' + accessToken
Url params:
Parameter | type | Description |
---|---|---|
codename | String | Request the Chat-Tonic team. |
Query params:
Parameter | type | Description |
---|---|---|
skip | String | Default 0. |
limit | String | Default and max value 100. |
query | Object | Optional value Valid status values: |
Sort params:
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
{
"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:
{{baseUrl}}/api/v1/{{codename}}/query
Header:
Accept: 'application/json'
Content-Type: 'application/json'
Authorization: 'Bearer ' + accessToken
Url params:
Parameter | type | Description |
---|---|---|
codename | String | Request the Chat-Tonic team. |
Request params:
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:
{
"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
{
"_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:
{{baseUrl}}/api/v1/{{codename}}/query/take/:queryId
Header:
Accept: 'application/json'
Content-Type: 'application/json'
Authorization: 'Bearer ' + accessToken
Url params:
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.
{
"ok": true,
"query": "5da0a9afb5509127ce79ff67",
"operator": {
"_id": "59db8ee6127acf48c5c737b4",
"displayName": "Me Operator",
"name": {
"familyName": "Operator",
"givenName": "Me"
}
}
}
4. PUT /query/assign
Method: PUT
Pathname:
{{baseUrl}}/api/v1/{{codename}}/query/assign/:queryId/to/:userId
Header:
Accept: 'application/json'
Content-Type: 'application/json'
Authorization: 'Bearer ' + accessToken
Url params:
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.
{
"ok": true,
"query": "5da0a9afb5509127ce79ff67",
"operator": {
"_id": "59db8ee6127acf48c5c737b4",
"displayName": "Other Operator",
"name": {
"familyName": "Operator",
"givenName": "Other"
}
}
}
5. PUT /query/resolve
Method: PUT
Pathname:
{{baseUrl}}/api/v1/{{codename}}/query/resolve/:queryId
Header:
Accept: 'application/json'
Content-Type: 'application/json'
Authorization: 'Bearer ' + accessToken
Url params:
Parameter | type | Description |
---|---|---|
codename | String | Request the Chat-Tonic team. |
queryId | String | Query ID |
Response:
Mark the query as resolved.
{
"ok": true,
"query": "5da0a9afb5509127ce79ff67"
}