Replace routing rules
curl --request PUT \
--url https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"rules": [
{
"name": "Existing customers",
"conditions": [
{
"field": "first_message_text",
"operator": "regex",
"value": "(my order|tracking|refund)"
}
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333",
"is_active": true
},
{
"name": "Chile web leads",
"conditions": [
{
"field": "channel",
"operator": "eq",
"value": "webchat"
},
{
"field": "metadata.country",
"operator": "eq",
"value": "CL"
}
],
"target_workflow_id": "55555555-5555-4555-8555-555555555555"
}
],
"confirm": true
}
'import requests
url = "https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules"
payload = {
"rules": [
{
"name": "Existing customers",
"conditions": [
{
"field": "first_message_text",
"operator": "regex",
"value": "(my order|tracking|refund)"
}
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333",
"is_active": True
},
{
"name": "Chile web leads",
"conditions": [
{
"field": "channel",
"operator": "eq",
"value": "webchat"
},
{
"field": "metadata.country",
"operator": "eq",
"value": "CL"
}
],
"target_workflow_id": "55555555-5555-4555-8555-555555555555"
}
],
"confirm": True
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
rules: [
{
name: 'Existing customers',
conditions: [
{
field: 'first_message_text',
operator: 'regex',
value: '(my order|tracking|refund)'
}
],
target_workflow_id: '33333333-3333-4333-8333-333333333333',
is_active: true
},
{
name: 'Chile web leads',
conditions: [
{field: 'channel', operator: 'eq', value: 'webchat'},
{field: 'metadata.country', operator: 'eq', value: 'CL'}
],
target_workflow_id: '55555555-5555-4555-8555-555555555555'
}
],
confirm: true
})
};
fetch('https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'rules' => [
[
'name' => 'Existing customers',
'conditions' => [
[
'field' => 'first_message_text',
'operator' => 'regex',
'value' => '(my order|tracking|refund)'
]
],
'target_workflow_id' => '33333333-3333-4333-8333-333333333333',
'is_active' => true
],
[
'name' => 'Chile web leads',
'conditions' => [
[
'field' => 'channel',
'operator' => 'eq',
'value' => 'webchat'
],
[
'field' => 'metadata.country',
'operator' => 'eq',
'value' => 'CL'
]
],
'target_workflow_id' => '55555555-5555-4555-8555-555555555555'
]
],
'confirm' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules"
payload := strings.NewReader("{\n \"rules\": [\n {\n \"name\": \"Existing customers\",\n \"conditions\": [\n {\n \"field\": \"first_message_text\",\n \"operator\": \"regex\",\n \"value\": \"(my order|tracking|refund)\"\n }\n ],\n \"target_workflow_id\": \"33333333-3333-4333-8333-333333333333\",\n \"is_active\": true\n },\n {\n \"name\": \"Chile web leads\",\n \"conditions\": [\n {\n \"field\": \"channel\",\n \"operator\": \"eq\",\n \"value\": \"webchat\"\n },\n {\n \"field\": \"metadata.country\",\n \"operator\": \"eq\",\n \"value\": \"CL\"\n }\n ],\n \"target_workflow_id\": \"55555555-5555-4555-8555-555555555555\"\n }\n ],\n \"confirm\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"rules\": [\n {\n \"name\": \"Existing customers\",\n \"conditions\": [\n {\n \"field\": \"first_message_text\",\n \"operator\": \"regex\",\n \"value\": \"(my order|tracking|refund)\"\n }\n ],\n \"target_workflow_id\": \"33333333-3333-4333-8333-333333333333\",\n \"is_active\": true\n },\n {\n \"name\": \"Chile web leads\",\n \"conditions\": [\n {\n \"field\": \"channel\",\n \"operator\": \"eq\",\n \"value\": \"webchat\"\n },\n {\n \"field\": \"metadata.country\",\n \"operator\": \"eq\",\n \"value\": \"CL\"\n }\n ],\n \"target_workflow_id\": \"55555555-5555-4555-8555-555555555555\"\n }\n ],\n \"confirm\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"rules\": [\n {\n \"name\": \"Existing customers\",\n \"conditions\": [\n {\n \"field\": \"first_message_text\",\n \"operator\": \"regex\",\n \"value\": \"(my order|tracking|refund)\"\n }\n ],\n \"target_workflow_id\": \"33333333-3333-4333-8333-333333333333\",\n \"is_active\": true\n },\n {\n \"name\": \"Chile web leads\",\n \"conditions\": [\n {\n \"field\": \"channel\",\n \"operator\": \"eq\",\n \"value\": \"webchat\"\n },\n {\n \"field\": \"metadata.country\",\n \"operator\": \"eq\",\n \"value\": \"CL\"\n }\n ],\n \"target_workflow_id\": \"55555555-5555-4555-8555-555555555555\"\n }\n ],\n \"confirm\": true\n}"
response = http.request(request)
puts response.read_body{
"agent_group_id": "11111111-1111-4111-8111-111111111111",
"rules": [
{
"id": "9b2f7c1e-0000-4000-8000-000000000002",
"position": 0,
"name": "Existing customers",
"conditions": [
{
"field": "first_message_text",
"operator": "regex",
"value": "(my order|tracking|refund)"
}
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333",
"is_active": true
},
{
"id": "9b2f7c1e-0000-4000-8000-000000000003",
"position": 1,
"is_active": true,
"name": "Chile web leads",
"conditions": [
{
"field": "channel",
"operator": "eq",
"value": "webchat"
},
{
"field": "metadata.country",
"operator": "eq",
"value": "CL"
}
],
"target_workflow_id": "55555555-5555-4555-8555-555555555555"
}
]
}{
"error": "invalid_rule_target_workflow"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "inbound_router_not_enabled"
}{
"error": "agent_group_not_found"
}{
"error": "internal_error"
}Reemplazar reglas de enrutamiento
Reemplaza todas las reglas de enrutamiento de un agente en una sola llamada. El orden del arreglo define la prioridad. Requiere confirm: true.
PUT
/
master-workflows
/
{id}
/
router
/
rules
Replace routing rules
curl --request PUT \
--url https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"rules": [
{
"name": "Existing customers",
"conditions": [
{
"field": "first_message_text",
"operator": "regex",
"value": "(my order|tracking|refund)"
}
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333",
"is_active": true
},
{
"name": "Chile web leads",
"conditions": [
{
"field": "channel",
"operator": "eq",
"value": "webchat"
},
{
"field": "metadata.country",
"operator": "eq",
"value": "CL"
}
],
"target_workflow_id": "55555555-5555-4555-8555-555555555555"
}
],
"confirm": true
}
'import requests
url = "https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules"
payload = {
"rules": [
{
"name": "Existing customers",
"conditions": [
{
"field": "first_message_text",
"operator": "regex",
"value": "(my order|tracking|refund)"
}
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333",
"is_active": True
},
{
"name": "Chile web leads",
"conditions": [
{
"field": "channel",
"operator": "eq",
"value": "webchat"
},
{
"field": "metadata.country",
"operator": "eq",
"value": "CL"
}
],
"target_workflow_id": "55555555-5555-4555-8555-555555555555"
}
],
"confirm": True
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
rules: [
{
name: 'Existing customers',
conditions: [
{
field: 'first_message_text',
operator: 'regex',
value: '(my order|tracking|refund)'
}
],
target_workflow_id: '33333333-3333-4333-8333-333333333333',
is_active: true
},
{
name: 'Chile web leads',
conditions: [
{field: 'channel', operator: 'eq', value: 'webchat'},
{field: 'metadata.country', operator: 'eq', value: 'CL'}
],
target_workflow_id: '55555555-5555-4555-8555-555555555555'
}
],
confirm: true
})
};
fetch('https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'rules' => [
[
'name' => 'Existing customers',
'conditions' => [
[
'field' => 'first_message_text',
'operator' => 'regex',
'value' => '(my order|tracking|refund)'
]
],
'target_workflow_id' => '33333333-3333-4333-8333-333333333333',
'is_active' => true
],
[
'name' => 'Chile web leads',
'conditions' => [
[
'field' => 'channel',
'operator' => 'eq',
'value' => 'webchat'
],
[
'field' => 'metadata.country',
'operator' => 'eq',
'value' => 'CL'
]
],
'target_workflow_id' => '55555555-5555-4555-8555-555555555555'
]
],
'confirm' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules"
payload := strings.NewReader("{\n \"rules\": [\n {\n \"name\": \"Existing customers\",\n \"conditions\": [\n {\n \"field\": \"first_message_text\",\n \"operator\": \"regex\",\n \"value\": \"(my order|tracking|refund)\"\n }\n ],\n \"target_workflow_id\": \"33333333-3333-4333-8333-333333333333\",\n \"is_active\": true\n },\n {\n \"name\": \"Chile web leads\",\n \"conditions\": [\n {\n \"field\": \"channel\",\n \"operator\": \"eq\",\n \"value\": \"webchat\"\n },\n {\n \"field\": \"metadata.country\",\n \"operator\": \"eq\",\n \"value\": \"CL\"\n }\n ],\n \"target_workflow_id\": \"55555555-5555-4555-8555-555555555555\"\n }\n ],\n \"confirm\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"rules\": [\n {\n \"name\": \"Existing customers\",\n \"conditions\": [\n {\n \"field\": \"first_message_text\",\n \"operator\": \"regex\",\n \"value\": \"(my order|tracking|refund)\"\n }\n ],\n \"target_workflow_id\": \"33333333-3333-4333-8333-333333333333\",\n \"is_active\": true\n },\n {\n \"name\": \"Chile web leads\",\n \"conditions\": [\n {\n \"field\": \"channel\",\n \"operator\": \"eq\",\n \"value\": \"webchat\"\n },\n {\n \"field\": \"metadata.country\",\n \"operator\": \"eq\",\n \"value\": \"CL\"\n }\n ],\n \"target_workflow_id\": \"55555555-5555-4555-8555-555555555555\"\n }\n ],\n \"confirm\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"rules\": [\n {\n \"name\": \"Existing customers\",\n \"conditions\": [\n {\n \"field\": \"first_message_text\",\n \"operator\": \"regex\",\n \"value\": \"(my order|tracking|refund)\"\n }\n ],\n \"target_workflow_id\": \"33333333-3333-4333-8333-333333333333\",\n \"is_active\": true\n },\n {\n \"name\": \"Chile web leads\",\n \"conditions\": [\n {\n \"field\": \"channel\",\n \"operator\": \"eq\",\n \"value\": \"webchat\"\n },\n {\n \"field\": \"metadata.country\",\n \"operator\": \"eq\",\n \"value\": \"CL\"\n }\n ],\n \"target_workflow_id\": \"55555555-5555-4555-8555-555555555555\"\n }\n ],\n \"confirm\": true\n}"
response = http.request(request)
puts response.read_body{
"agent_group_id": "11111111-1111-4111-8111-111111111111",
"rules": [
{
"id": "9b2f7c1e-0000-4000-8000-000000000002",
"position": 0,
"name": "Existing customers",
"conditions": [
{
"field": "first_message_text",
"operator": "regex",
"value": "(my order|tracking|refund)"
}
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333",
"is_active": true
},
{
"id": "9b2f7c1e-0000-4000-8000-000000000003",
"position": 1,
"is_active": true,
"name": "Chile web leads",
"conditions": [
{
"field": "channel",
"operator": "eq",
"value": "webchat"
},
{
"field": "metadata.country",
"operator": "eq",
"value": "CL"
}
],
"target_workflow_id": "55555555-5555-4555-8555-555555555555"
}
]
}{
"error": "invalid_rule_target_workflow"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "inbound_router_not_enabled"
}{
"error": "agent_group_not_found"
}{
"error": "internal_error"
}Esta llamada reemplaza la lista completa. Para agregar, editar o reordenar una sola regla, lee la lista con Listar reglas, modifícala y envíala completa.
Las comparaciones de texto no distinguen mayúsculas de minúsculas. Antes de salir en vivo, revisa el orden con Probar un mensaje.
- El orden del arreglo es la prioridad: la primera regla se revisa primero.
rules: []elimina todas las reglas.- Cada regla guardada recibe un
idnuevo. - Si una regla no es válida, no se guarda nada.
target_workflow_iddebe ser una de las tareas del agente; si no, la API responde 400invalid_rule_target_workflow.
{
"rules": [
{
"name": "Existing customers",
"conditions": [
{ "field": "first_message_text", "operator": "regex", "value": "(my order|tracking|refund)" }
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333"
},
{
"name": "Web chat from Chile",
"conditions": [
{ "field": "channel", "operator": "eq", "value": "webchat" },
{ "field": "metadata.country", "operator": "eq", "value": "CL" }
],
"target_workflow_id": "22222222-2222-4222-8222-222222222222"
}
],
"confirm": true
}
Condiciones
Todas las condiciones de una regla deben cumplirse. Una regla sin condiciones se cumple para cualquier conversación, así que déjala al final.field | Qué revisa |
|---|---|
channel | Canal de la conversación, como whatsapp, webchat o email. |
first_message_text | El primer mensaje del lead. |
source | De dónde vino el lead, según lo guardado en el lead. |
phone, email | El teléfono y el email del lead. |
tags | Las etiquetas del lead. |
metadata.country | Cualquier valor de la metadata del lead, escrito como ruta con puntos. |
operator | Se cumple cuando el valor |
|---|---|
eq, neq | es igual, o distinto. |
gt, gte, lt, lte | es mayor o menor que un número. |
contains, not_contains | contiene un texto, o no lo contiene. |
in, not_in | es uno de los valores de un arreglo, o ninguno de ellos. |
regex | coincide con una expresión regular. |
exists, not_exists | tiene un valor, o no tiene ninguno. Estos dos no usan value. |
Autorizaciones
API key for authentication. Keys are prefixed with nxr_live_.
Parámetros de ruta
Agent ID (master_workflow in the API). A malformed ID returns 400 invalid_group_id.
Cuerpo
application/json
Última modificación el 28 de septiembre de 2026
⌘I