curl --request POST \
--url https://seudominio.com/webhooks/on-condition \
--header 'Content-Type: application/json' \
--data '
{
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "abcsderfwer3252432423-1324325235",
"conversation_id": 1234,
"variable": {
"name": "age",
"value": "18"
},
"condition": {
"operator": "EQ",
"value": "18"
},
"user_session_keys": [
{
"key": "age",
"value": "18",
"type": null
},
{
"key": "user_id",
"value": "12345",
"type": null
}
]
}
'import requests
url = "https://seudominio.com/webhooks/on-condition"
payload = {
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "abcsderfwer3252432423-1324325235",
"conversation_id": 1234,
"variable": {
"name": "age",
"value": "18"
},
"condition": {
"operator": "EQ",
"value": "18"
},
"user_session_keys": [
{
"key": "age",
"value": "18",
"type": None
},
{
"key": "user_id",
"value": "12345",
"type": None
}
]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
country_code: '+57',
cellphone: '3161234567',
session_id: 'abcsderfwer3252432423-1324325235',
conversation_id: 1234,
variable: {name: 'age', value: '18'},
condition: {operator: 'EQ', value: '18'},
user_session_keys: [
{key: 'age', value: '18', type: null},
{key: 'user_id', value: '12345', type: null}
]
})
};
fetch('https://seudominio.com/webhooks/on-condition', 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://seudominio.com/webhooks/on-condition",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'country_code' => '+57',
'cellphone' => '3161234567',
'session_id' => 'abcsderfwer3252432423-1324325235',
'conversation_id' => 1234,
'variable' => [
'name' => 'age',
'value' => '18'
],
'condition' => [
'operator' => 'EQ',
'value' => '18'
],
'user_session_keys' => [
[
'key' => 'age',
'value' => '18',
'type' => null
],
[
'key' => 'user_id',
'value' => '12345',
'type' => null
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://seudominio.com/webhooks/on-condition"
payload := strings.NewReader("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"abcsderfwer3252432423-1324325235\",\n \"conversation_id\": 1234,\n \"variable\": {\n \"name\": \"age\",\n \"value\": \"18\"\n },\n \"condition\": {\n \"operator\": \"EQ\",\n \"value\": \"18\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"age\",\n \"value\": \"18\",\n \"type\": null\n },\n {\n \"key\": \"user_id\",\n \"value\": \"12345\",\n \"type\": null\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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.post("https://seudominio.com/webhooks/on-condition")
.header("Content-Type", "application/json")
.body("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"abcsderfwer3252432423-1324325235\",\n \"conversation_id\": 1234,\n \"variable\": {\n \"name\": \"age\",\n \"value\": \"18\"\n },\n \"condition\": {\n \"operator\": \"EQ\",\n \"value\": \"18\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"age\",\n \"value\": \"18\",\n \"type\": null\n },\n {\n \"key\": \"user_id\",\n \"value\": \"12345\",\n \"type\": null\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://seudominio.com/webhooks/on-condition")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"abcsderfwer3252432423-1324325235\",\n \"conversation_id\": 1234,\n \"variable\": {\n \"name\": \"age\",\n \"value\": \"18\"\n },\n \"condition\": {\n \"operator\": \"EQ\",\n \"value\": \"18\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"age\",\n \"value\": \"18\",\n \"type\": null\n },\n {\n \"key\": \"user_id\",\n \"value\": \"12345\",\n \"type\": null\n }\n ]\n}"
response = http.request(request)
puts response.read_body{}Corpo da Solicitação Webhook do Nó de Condição
Este endpoint deve ser implementado no SEU servidor (por exemplo: https://seudominio.com/webhooks/on-condition). O Treble chamará este webhook quando um nó condicional for avaliado na conversa. Você deve configurar a URL deste webhook no painel de administração do Treble.
curl --request POST \
--url https://seudominio.com/webhooks/on-condition \
--header 'Content-Type: application/json' \
--data '
{
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "abcsderfwer3252432423-1324325235",
"conversation_id": 1234,
"variable": {
"name": "age",
"value": "18"
},
"condition": {
"operator": "EQ",
"value": "18"
},
"user_session_keys": [
{
"key": "age",
"value": "18",
"type": null
},
{
"key": "user_id",
"value": "12345",
"type": null
}
]
}
'import requests
url = "https://seudominio.com/webhooks/on-condition"
payload = {
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "abcsderfwer3252432423-1324325235",
"conversation_id": 1234,
"variable": {
"name": "age",
"value": "18"
},
"condition": {
"operator": "EQ",
"value": "18"
},
"user_session_keys": [
{
"key": "age",
"value": "18",
"type": None
},
{
"key": "user_id",
"value": "12345",
"type": None
}
]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
country_code: '+57',
cellphone: '3161234567',
session_id: 'abcsderfwer3252432423-1324325235',
conversation_id: 1234,
variable: {name: 'age', value: '18'},
condition: {operator: 'EQ', value: '18'},
user_session_keys: [
{key: 'age', value: '18', type: null},
{key: 'user_id', value: '12345', type: null}
]
})
};
fetch('https://seudominio.com/webhooks/on-condition', 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://seudominio.com/webhooks/on-condition",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'country_code' => '+57',
'cellphone' => '3161234567',
'session_id' => 'abcsderfwer3252432423-1324325235',
'conversation_id' => 1234,
'variable' => [
'name' => 'age',
'value' => '18'
],
'condition' => [
'operator' => 'EQ',
'value' => '18'
],
'user_session_keys' => [
[
'key' => 'age',
'value' => '18',
'type' => null
],
[
'key' => 'user_id',
'value' => '12345',
'type' => null
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://seudominio.com/webhooks/on-condition"
payload := strings.NewReader("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"abcsderfwer3252432423-1324325235\",\n \"conversation_id\": 1234,\n \"variable\": {\n \"name\": \"age\",\n \"value\": \"18\"\n },\n \"condition\": {\n \"operator\": \"EQ\",\n \"value\": \"18\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"age\",\n \"value\": \"18\",\n \"type\": null\n },\n {\n \"key\": \"user_id\",\n \"value\": \"12345\",\n \"type\": null\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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.post("https://seudominio.com/webhooks/on-condition")
.header("Content-Type", "application/json")
.body("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"abcsderfwer3252432423-1324325235\",\n \"conversation_id\": 1234,\n \"variable\": {\n \"name\": \"age\",\n \"value\": \"18\"\n },\n \"condition\": {\n \"operator\": \"EQ\",\n \"value\": \"18\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"age\",\n \"value\": \"18\",\n \"type\": null\n },\n {\n \"key\": \"user_id\",\n \"value\": \"12345\",\n \"type\": null\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://seudominio.com/webhooks/on-condition")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"abcsderfwer3252432423-1324325235\",\n \"conversation_id\": 1234,\n \"variable\": {\n \"name\": \"age\",\n \"value\": \"18\"\n },\n \"condition\": {\n \"operator\": \"EQ\",\n \"value\": \"18\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"age\",\n \"value\": \"18\",\n \"type\": null\n },\n {\n \"key\": \"user_id\",\n \"value\": \"12345\",\n \"type\": null\n }\n ]\n}"
response = http.request(request)
puts response.read_body{}
{
"condition": {
"operator": "EQ",
"value": "18"
}
}
operator para mostrar qual ação foi usada na condição e um value para que a ação da condição seja avaliada:
- Igual: EQ
- Diferente: DIFF
- Maior que: GT
- Menor que: LT
- Maior ou igual que: GTEQ
- Menor ou igual que: LTEQ
- Contém: CONT
- Não contém: NCONT
- Caminho padrão: DEFAULT
user_session_keys.Corpo
Informações do evento de avaliação de condição
Evento que é disparado quando um nó condicional é avaliado na conversa
Código de país del usuario
Número de teléfono del usuario sin el código de país
ID de la sesión del usuario
ID de la conversación
Variável que é avaliada na condição
Show child attributes
Show child attributes
Condição que é avaliada
Show child attributes
Show child attributes
Claves de sesión del usuario recopiladas durante la conversación o proporcionadas durante el despliegue
Show child attributes
Show child attributes
Resposta
Resposta para atualizar ou adicionar informações à sessão
Objeto JSON com as novas informações que serão substituídas ou adicionadas à sessão para uso futuro. O serviço deve responder em menos de 10 segundos.
Esta página foi útil?