Create Empty Scenario
curl --request POST \
--url https://{projectID}.texterchat.com/server/api/v2/scenarios/manage \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My custom automation",
"triggerEvent": "domain.chat.resolved"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'My custom automation', triggerEvent: 'domain.chat.resolved'})
};
fetch('https://{projectID}.texterchat.com/server/api/v2/scenarios/manage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{projectID}.texterchat.com/server/api/v2/scenarios/manage"
payload = {
"name": "My custom automation",
"triggerEvent": "domain.chat.resolved"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"_id": "6970b3c1d2e3f40123456789",
"drafts": [],
"inactiveRevisions": [],
"activeRevision": {
"_id": "6970b3c1d2e3f4012345678a",
"scenarioId": "6970b3c1d2e3f40123456789",
"name": "(SUB) New Incoming Messages",
"description": "Sends a webhook for each new incoming message",
"status": "active",
"version": 1,
"triggerEvents": [
"domain.message.created"
],
"conditions": [
[
{
"name": "filtrex",
"params": {
"expression": "direction == \"incoming\""
},
"confidentialData": false
}
]
],
"loaders": {
"afterConditions": [
{
"name": "chat",
"alias": "chat",
"params": {},
"confidentialData": false
}
]
},
"actions": [
{
"name": "request",
"params": {
"url": "https://example.com/hook",
"method": "post",
"json": true
},
"confidentialData": false
}
],
"options": {
"unorderedActions": false
},
"metadata": {
"authorUid": "4d170fc7-5cd6-4496-98e4-f4f03a11456e",
"created": 1768314807488,
"activated": 1768314808000
}
}
}{
"error": "<string>"
}Scenarios (Advanced)
Create Empty Scenario
Create a new, empty scenario as a draft with a single trigger event. Build its loaders, conditions and actions afterwards with the Update Draft operations, then publish it with Create Revision. For webhook subscriptions, the simpler path is Import Subscription with a ready template.
POST
https://{projectID}.texterchat.com/server/api/v2
/
scenarios
/
manage
Create Empty Scenario
curl --request POST \
--url https://{projectID}.texterchat.com/server/api/v2/scenarios/manage \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My custom automation",
"triggerEvent": "domain.chat.resolved"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'My custom automation', triggerEvent: 'domain.chat.resolved'})
};
fetch('https://{projectID}.texterchat.com/server/api/v2/scenarios/manage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{projectID}.texterchat.com/server/api/v2/scenarios/manage"
payload = {
"name": "My custom automation",
"triggerEvent": "domain.chat.resolved"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"_id": "6970b3c1d2e3f40123456789",
"drafts": [],
"inactiveRevisions": [],
"activeRevision": {
"_id": "6970b3c1d2e3f4012345678a",
"scenarioId": "6970b3c1d2e3f40123456789",
"name": "(SUB) New Incoming Messages",
"description": "Sends a webhook for each new incoming message",
"status": "active",
"version": 1,
"triggerEvents": [
"domain.message.created"
],
"conditions": [
[
{
"name": "filtrex",
"params": {
"expression": "direction == \"incoming\""
},
"confidentialData": false
}
]
],
"loaders": {
"afterConditions": [
{
"name": "chat",
"alias": "chat",
"params": {},
"confidentialData": false
}
]
},
"actions": [
{
"name": "request",
"params": {
"url": "https://example.com/hook",
"method": "post",
"json": true
},
"confidentialData": false
}
],
"options": {
"unorderedActions": false
},
"metadata": {
"authorUid": "4d170fc7-5cd6-4496-98e4-f4f03a11456e",
"created": 1768314807488,
"activated": 1768314808000
}
}
}{
"error": "<string>"
}Required token scopes:
Create scenarios, Manage scenarios on behalf of user (both are required)
Note: unlike the other scenario-management operations, this endpoint does not accept an authorUid field (unknown body fields are rejected with 400).הרשאות
גוף
application/json
תגובה
The created scenario (as a draft). Field-by-field reference: The Scenario object
An event subscription (scenario) in Texter