PBScripts
Esta página aún no se encuentra traducida al español.
Overview
A PBScript (parametrized bot script) is a routine that can be created and saved for later use as a stage in any routine builder.
These are just some of the most basic API requests. For a complete list of endpoints, consult our API documentation on Swagger.
Get PBScripts
Lists the PBScripts in the company.
GET /pbscriptsEndpoint URL
https://www.cotalker.com/api/v2/pbscripts
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 |
Admin | Grants administrative access to view PBScripts. | Required | true |
Query Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
limit | Limits the amount of routines that are 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 | |
count | Adds the counter field with the total amount of routines. | boolean | Optional | |
orderBy | Orders the routines by ascending or descending order according to the value of the sortBy field. | string | Optional | Options: asc , desc |
sortBy | Sorts the routines by the indicated value. | string | Optional | Options: createdAt , modifiedAt , collectionName |
isActive | Returns routines that are active according to their isActive field. | string | Optional | all , true , false |
debug | Adds the debug field with error notificaciones. | string | Optional | Option: true |
Request Sample
curl --location --request GET 'https://www.cotalker.com/api/v2/pbscripts' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN'
Response Sample
Responses follow the COTPBScript data model.
Get PBScripts by Id
Returns the inidicated routines.
GET /pbscripts/{id}Endpoint URL
https://www.cotalker.com/api/v2/pbscripts/{id}
Path Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
id | The ObjectId of the routine that is to be returned. | ObjectId<COTPBScript> | Required |
Headers
Header | Description | Required | Values |
---|---|---|---|
Admin | Gives administrative access to the endpoint. | Optional | 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 |
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/pbscripts/61af6469c80d5d9498753673' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN'
Response Sample
The response follows the COTPBScript data model.
Create New PBScript
Create a new routine within the company.
POST /pbscriptsEndpoint URL
https://www.cotalker.com/api/v2/pbscripts
Headers
Header | Description | Required | Values |
---|---|---|---|
Admin | Grants administrative access to create a new routine. | 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
Field | 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 COTPBScript data model. Unrequired fields that are not submitted are either filled in automatically or left blank.
Element | Description | Type | Required | Notes |
---|---|---|---|---|
code | The routine's unique code name. | string | Required | Maximum 60 characters; only lowercase letters, numbers, and underscores allowed; must be unique. |
documentation | Contains the structure and descriptions of the various fields used to set up the routine. | object | Required | WIP |
documentation.key | Indicates the documentation's code name. | string | Required | The value usually repeats the code field. |
Request Sample
Routine created with minimum required fields.
curl --location --request POST 'https://www.cotalker.com/api/v2/pbscripts?debug=true' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--data-raw '{
"code": "sendemail_00",
"documentation": {
"key": "sendemail_00"
}
}'
Response Sample
Go to COTPBScripts for a complete description of the response.
{
"data": {
"parametrizedBot": {
"default": {
"stages": []
},
"stages": []
},
"isActive": true,
"_id": "61afbfa726427d00078c4949",
"code": "sendemail_00",
"documentation": {
"key": "sendemail_00",
"dataType": [],
"nextType": []
},
"company": "6136968b580aaf2b0e49d844",
"createdAt": "2021-12-07T20:10:15.355Z",
"modifiedAt": "2021-12-07T20:10:15.357Z",
"__v": 0
},
"debug": {
"data": {
"body": {
"code": "sendemail_00",
"documentation": {
"key": "sendemail_00"
}
}
}
}
}
Update PBScript
Updates or edits the indicated routine.
PATCH /pbscripts/{id}Endpoint URL
https://www.cotalker.com/api/v2/pbscripts/{id}
Path Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
id | The routine's ID. | ObjectId<COTPBScripts> | Required |
Headers
Header | Description | Required | Values |
---|---|---|---|
Admin | Grants administrative access to edit the routine. | 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 |
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 COTPBScripts data model.
Request Sample
curl --location --request PATCH 'https://www.cotalker.com/api/v2/pbscripts/61af6469c80d5d9498753673' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"parametrizedBot": {
"maxIterations": 2,
"stages": [
{
"_id": "618a6968eec811dbba542170",
"key": "email",
"name": "PBEmail",
"version": null,
"data": {
"subject": "Hey! We need to talk to you.",
"content": {
"recipientName": "",
"recipientEmail": "",
"companyName": "ACME",
"title": [
"Your team is looking for you."
],
"action": "",
"code": "",
"messageA": "$JOIN# #Your presence is requested in the #($VALUE#channel|nameDisplay)# channel.",
"messageB": ""
},
"targets": [
"$VALUE#cmdArgs"
]
},
"next": {
"DEFAULT": "message"
},
"customNetworkRequest": []
},
{
"_id": "618a6974b4b9f668deab7b3e",
"key": "message",
"name": "PBMessage",
"data": {
"content": "📩 Email sent ✅",
"contentType": "text/system",
"sentBy": "$VALUE#user|_id",
"channelIds": "$VALUE#channel|_id"
},
"next": {},
"customNetworkRequest": []
}
],
"start": "email",
"version": "v3"
}
}'
Response Sample
Go to COTPBScripts for a complete description of the response.
{
"parametrizedBot": {
"default": {
"stages": []
},
"stages": [
{
"_id": "618a6968eec811dbba542170",
"key": "email",
"name": "PBEmail",
"version": null,
"data": {
"subject": "Hey! We need to talk to you.",
"content": {
"recipientName": "",
"recipientEmail": "",
"companyName": "ACME",
"title": [
"Your team is looking for you."
],
"action": "",
"code": "",
"messageA": "$JOIN# #Your presence is requested in the #($VALUE#channel|nameDisplay)# channel.",
"messageB": ""
},
"targets": [
"$VALUE#cmdArgs"
]
},
"next": {
"DEFAULT": "message"
},
"customNetworkRequest": []
},
{
"_id": "618a6974b4b9f668deab7b3e",
"key": "message",
"name": "PBMessage",
"data": {
"content": "📩 Email sent ✅",
"contentType": "text/system",
"sentBy": "$VALUE#user|_id",
"channelIds": "$VALUE#channel|_id"
},
"next": {},
"customNetworkRequest": []
}
],
"maxIterations": 2,
"start": "email",
"version": "v3"
},
"documentation": {
"key": "sendemail_00",
"dataType": [],
"nextType": []
},
"isActive": true,
"_id": "61af6469c80d5d9498753673",
"code": "sendemail_00",
"company": "6136968b580aaf2b0e49d844",
"createdAt": "2021-12-07T20:10:15.355Z",
"modifiedAt": "2021-12-09T10:13:29.955Z",
"__v": 0
}