Survey Chats
Esta página aún no se encuentra traducida al español.
Overview
Survey chats represent a survey's components and hold together the questions that make up each specific component in a survey.
These are just some of the most basic API requests. For a complete list of endpoints, consult our API documentation on Swagger.
Get Survey Chats
Returns all survey chats within the company.
GET /surveychatsEndpoint URL
https://www.cotalker.com/api/v2/surveychats
Headers
Header | Description | Required | Values |
---|---|---|---|
Authorization | Sends your access token to make an API request. Click here to see how to obtain an access token. | Required | Bearer $ACCESS_TOKEN |
Query Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
limit | Limits the amount of survey chats returned in the response. | number | Optional | By default, the limit is set to 10. |
page | Makes the response display data from the indicated page number. | number | Optional | Best used in combination with the "limit" parameter. |
count | Adds the counter field with the total amount of survey chats within the company. | boolean | Optional | |
survey | Returns survey chats that correspond to the indicated survey. | ObjectId<COTSurvey>[ ] | ||
ids | Returns survey chats with the IDs indicated in the array. | ObjectId<COTSurveyChats>[ ] | Optional | |
modified | Returns survey chats with the indicated modification date in the modifiedAt field. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
modified_gt | Returns survey chats modified after the indicated date and time. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
modified_gte | Returns survey chats with a value in the modifiedAt field equal to or greater than the indicated date and time. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
modified_lt | Returns survey chats modified before the indicated date and time. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
modified_lte | Returns survey chats with a value in the modifiedAt field equal to or less than the indicated date and time. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
isActive | Returns survey chats according to their isActive status. | string | Optional | Options are: all , true , false |
debug | Adds the debug field with error notifications. | string | Optional | Option: true |
Request Samples
- cURL (default)
- cURL (query)
- Typescript (default)
This default request gets all the survey chats in the company.
curl --location --request GET 'https://www.cotalker.com/api/v2/surveychats' \
--header 'Authorization: Bearer $ACCESS_TOKEN'
This request gets the survey chats related to the indicated survey.
curl --location --request GET 'https://www.cotalker.com/api/v2/surveychats?survey=61a56d18d4ffd1354af8f4cd' \
--header 'Authorization: Bearer $ACCESS_TOKEN'
This example gets all the survey chats in the company.
// $ACCESS_TOKEN stored in .env file.
import { SurveyChatGetCollection, Configuration, V2SurveychatsApi} from "@cotalker/cotalker-api";
const api = new V2SurveychatsApi(new Configuration({
basePath: 'https://www.cotalker.com/api',
accessToken: process.env.ACCESS_TOKEN,
apiKey: 'true',
}));
async function getSurveyChats(): Promise<SurveyChatGetCollection | undefined> {
const response = await api.getV2Surveychats();
return response.data?.data;
}
getSurveyChats().then(surveyChats => console.log(surveyChats)).catch(e=>console.log(e))
Response Sample
Responses follow the COTSurveyChat data model.
Get a Survey Chat by Id
Returns the survey chat indicated by the Id.
GET /surveychats/{id}Endpoint URL
https://www.cotalker.com/api/v2/surveychats/{id}
Path Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
id | The ObjectId of the survey chat that is to be returned. | ObjectId<COTSurveyChat> | Required |
Headers
Header | Description | Required | Values |
---|---|---|---|
Authorization | Sends your access token to make an API request. Click here to see how to obtain an access token. | Required | Bearer $ACCESS_TOKEN |
Query Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
debug | Adds the debug field with error notifications. | string | Optional | Option: true |
Request Sample
curl --location --request GET 'https://www.cotalker.com/api/v2/surveychats/61a5ee4b54951757297e38de' \
--header 'Authorization: Bearer $ACCESS_TOKEN'
Response Sample
The response follows the COTSurveyChat data model.
Create a New Survey Chat
Creates a new survey chat within a survey.
POST /surveychatsEndpoint URL
https://www.cotalker.com/api/v2/surveychats
Headers
Header | Description | Required | Values |
---|---|---|---|
Admin | Grants administrative access to create a new survey chat. | Required | true |
Authorization | Sends your access token to make an API request. Click here to see how to obtain an access token. | Required | Bearer $ACCESS_TOKEN |
Content-Type | Indicates the body's format. | Required | application/json |
Query Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
debug | Adds the debug field with error notifications. | string | Optional | Option: true |
Request Body
Only required fields are listed below. For a complete schema description, please go to the COTSurvey data model. Unrequired fields that are not submitted are either filled in automatically or left blank.
Element | Description | Type | Required | Notes |
---|---|---|---|---|
contentType | Indicates the content type | string | Required | Default value: application/vnd.cotalker.survey |
order | Indicates the represented question's place on the survey form | number | Required | Lower numbers are higher on top |
sender | Indicates origin | string | Required | Options: #system , #user |
survey | Indicates the survey the question corresponds to | ObjectId<COTSurvey> | Survey data model | Required |
Request Sample
Survey chat created with the minimum required fields:
curl --location --request POST 'https://www.cotalker.com/api/v2/surveychats' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"survey": "61a50f928843af3e1332c67f",
"sender": "#user",
"order": 10,
"contentType": "application/vnd.cotalker.survey"
}'
Response Sample
Go to COTSurveyChat for a complete description of the response.
{
"content": "",
"contentArray": [],
"isActive": true,
"isSystemModel": false,
"_id": "61a5f3b86b2d27160918dc37",
"survey": "61a50f928843af3e1332c67f",
"sender": "#user",
"order": 10,
"contentType": "application/vnd.cotalker.survey",
"modifiedAt": "2021-11-30T09:43:07.667Z",
"__v": 0
}
Update a Survey Chat
Updates or edits an existing survey chat.
PATCH /surveychats/{id}Endpoint URL
https://www.cotalker.com/api/v2/surveychats/{id}
Path Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
id | The ObjectId of the survey chat that is to be modified. | ObjectId<COTSurveyChat> | Required |
Headers
Header | Description | Required | Values |
---|---|---|---|
Admin | Grants administrative access to modify a survey chat. | Required | true |
Authorization | Sends your access token to make an API request. Click here to see how to obtain an access token. | Required | Bearer $ACCESS_TOKEN |
Content-Type | Sets the body's format. | Required | application/json |
Query Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
debug | Adds the debug field with error notifications. | string | Optional | Option: true |
Request Body
Only the fields that are being updated or added are required to be put into the body. For a complete schema description, please go to the COTSurveyChat data model.
Request Sample
This sample adds two questions into the contentArray field:
curl --location --request PATCH 'https://www.cotalker.com/api/v2/surveychats/61a5f3b86b2d27160918dc37?debug=true' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"contentArray" : [
"61436eb4dd1e5af41302eab6",
"61436eb4dd1e5a1e8302eab7"
]
}'
Response Sample
Go to COTSurveyChat for a complete description of the response.
{
"content": "",
"contentArray": [
"61436eb4dd1e5af41302eab6",
"61436eb4dd1e5a1e8302eab7"
],
"isActive": true,
"isSystemModel": false,
"_id": "61a5f3b86b2d27160918dc37",
"survey": "61a50f928843af3e1332c67f",
"sender": "#user",
"order": 10,
"contentType": "application/vnd.cotalker.survey",
"modifiedAt": "2021-11-30T09:53:38.142Z",
"__v": 1
}