Saltar al contendio prinicipal

PBScripts

Advertencia

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.

additional resources

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 /pbscripts

Endpoint URL

https://www.cotalker.com/api/v2/pbscripts

Headers

HeaderDescriptionRequiredValues
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN
AdminGrants administrative access to view PBScripts.Requiredtrue

Query Parameters

ParameterDescriptionTypeRequiredNotes
limitLimits the amount of routines that are returned in the response.numberOptionalBy default, the limit is set to 10.
pageMakes the response display data from the indicated page number.numberOptional
countAdds the counter field with the total amount of routines.booleanOptional
orderByOrders the routines by ascending or descending order according to the value of the sortBy field.stringOptionalOptions: asc, desc
sortBySorts the routines by the indicated value.stringOptionalOptions:
createdAt, modifiedAt, collectionName
isActiveReturns routines that are active according to their isActive field.stringOptionalall, true, false
debugAdds the debug field with error notificaciones.stringOptionalOption: 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

ParameterDescriptionTypeRequiredNotes
idThe ObjectId of the routine that is to be returned.ObjectId<COTPBScript>Required

Headers

HeaderDescriptionRequiredValues
AdminGives administrative access to the endpoint.Optionaltrue
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN

Query Parameters

ParameterDescriptionTypeRequiredNotes
debugAdds the debug field with error notifications.stringOptionalOption: 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 /pbscripts

Endpoint URL

https://www.cotalker.com/api/v2/pbscripts

Headers

HeaderDescriptionRequiredValues
AdminGrants administrative access to create a new routine.Requiredtrue
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN
Content-TypeIndicates the body's format.Requiredapplication/json

Query Parameters

FieldDescriptionTypeRequiredNotes
debugAdds the debug field with error notifications.stringOptionalOption: 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.

ElementDescriptionTypeRequiredNotes
codeThe routine's unique code name.stringRequiredMaximum 60 characters; only lowercase letters, numbers, and underscores allowed; must be unique.
documentationContains the structure and descriptions of the various fields used to set up the routine.objectRequiredWIP
documentation.keyIndicates the documentation's code name.stringRequiredThe 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

ParameterDescriptionTypeRequiredNotes
idThe routine's ID.ObjectId<COTPBScripts>Required

Headers

HeaderDescriptionRequiredValues
AdminGrants administrative access to edit the routine.Requiredtrue
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN
Content-TypeSets the body's format.Requiredapplication/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
}