curl --request POST \
--url https://tudominio.com/webhooks/on-timeout \
--header 'Content-Type: application/json' \
--data '
{
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "abcsderfwer3252432423-1324325235",
"conversation_id": 1234,
"question": {
"type": "open",
"text": "Hello world"
},
"timeout_at": "2021-10-07 08:53:22.572123",
"user_session_keys": [
{
"key": "age",
"value": "18",
"type": null
},
{
"key": "user_id",
"value": "12345",
"type": null
}
]
}
'import requests
url = "https://tudominio.com/webhooks/on-timeout"
payload = {
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "abcsderfwer3252432423-1324325235",
"conversation_id": 1234,
"question": {
"type": "open",
"text": "Hello world"
},
"timeout_at": "2021-10-07 08:53:22.572123",
"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,
question: {type: 'open', text: 'Hello world'},
timeout_at: '2021-10-07 08:53:22.572123',
user_session_keys: [
{key: 'age', value: '18', type: null},
{key: 'user_id', value: '12345', type: null}
]
})
};
fetch('https://tudominio.com/webhooks/on-timeout', 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://tudominio.com/webhooks/on-timeout",
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,
'question' => [
'type' => 'open',
'text' => 'Hello world'
],
'timeout_at' => '2021-10-07 08:53:22.572123',
'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://tudominio.com/webhooks/on-timeout"
payload := strings.NewReader("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"abcsderfwer3252432423-1324325235\",\n \"conversation_id\": 1234,\n \"question\": {\n \"type\": \"open\",\n \"text\": \"Hello world\"\n },\n \"timeout_at\": \"2021-10-07 08:53:22.572123\",\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://tudominio.com/webhooks/on-timeout")
.header("Content-Type", "application/json")
.body("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"abcsderfwer3252432423-1324325235\",\n \"conversation_id\": 1234,\n \"question\": {\n \"type\": \"open\",\n \"text\": \"Hello world\"\n },\n \"timeout_at\": \"2021-10-07 08:53:22.572123\",\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://tudominio.com/webhooks/on-timeout")
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 \"question\": {\n \"type\": \"open\",\n \"text\": \"Hello world\"\n },\n \"timeout_at\": \"2021-10-07 08:53:22.572123\",\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{}Cuerpo de la solicitud Webhook de timeout (flujo alterno)
Este endpoint debe ser implementado en TU servidor (por ejemplo: https://tudominio.com/webhooks/on-timeout). Treble llamará a este webhook cuando ocurra un timeout en la conversación (el usuario no responde dentro del tiempo establecido). Debes configurar la URL de este webhook en el panel de administración de Treble.
curl --request POST \
--url https://tudominio.com/webhooks/on-timeout \
--header 'Content-Type: application/json' \
--data '
{
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "abcsderfwer3252432423-1324325235",
"conversation_id": 1234,
"question": {
"type": "open",
"text": "Hello world"
},
"timeout_at": "2021-10-07 08:53:22.572123",
"user_session_keys": [
{
"key": "age",
"value": "18",
"type": null
},
{
"key": "user_id",
"value": "12345",
"type": null
}
]
}
'import requests
url = "https://tudominio.com/webhooks/on-timeout"
payload = {
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "abcsderfwer3252432423-1324325235",
"conversation_id": 1234,
"question": {
"type": "open",
"text": "Hello world"
},
"timeout_at": "2021-10-07 08:53:22.572123",
"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,
question: {type: 'open', text: 'Hello world'},
timeout_at: '2021-10-07 08:53:22.572123',
user_session_keys: [
{key: 'age', value: '18', type: null},
{key: 'user_id', value: '12345', type: null}
]
})
};
fetch('https://tudominio.com/webhooks/on-timeout', 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://tudominio.com/webhooks/on-timeout",
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,
'question' => [
'type' => 'open',
'text' => 'Hello world'
],
'timeout_at' => '2021-10-07 08:53:22.572123',
'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://tudominio.com/webhooks/on-timeout"
payload := strings.NewReader("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"abcsderfwer3252432423-1324325235\",\n \"conversation_id\": 1234,\n \"question\": {\n \"type\": \"open\",\n \"text\": \"Hello world\"\n },\n \"timeout_at\": \"2021-10-07 08:53:22.572123\",\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://tudominio.com/webhooks/on-timeout")
.header("Content-Type", "application/json")
.body("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"abcsderfwer3252432423-1324325235\",\n \"conversation_id\": 1234,\n \"question\": {\n \"type\": \"open\",\n \"text\": \"Hello world\"\n },\n \"timeout_at\": \"2021-10-07 08:53:22.572123\",\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://tudominio.com/webhooks/on-timeout")
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 \"question\": {\n \"type\": \"open\",\n \"text\": \"Hello world\"\n },\n \"timeout_at\": \"2021-10-07 08:53:22.572123\",\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{}
{
"timeout_at": "2021-10-07 08:53:22.572123"
}
user_session_keys.Cuerpo
Información del evento de timeout
Evento que se dispara cuando ocurre un timeout en la conversación (el usuario no responde dentro del tiempo establecido)
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
Pregunta que no recibió respuesta a tiempo
Show child attributes
Show child attributes
Fecha y hora en que ocurrió el timeout
Claves de sesión del usuario recopiladas durante la conversación o proporcionadas durante el despliegue
Show child attributes
Show child attributes
Respuesta
Respuesta para actualizar o agregar información a la sesión
Objeto JSON con la nueva información que será reemplazada o agregada a la sesión para uso futuro. El servicio debe responder en menos de 10 segundos.
¿Esta página le ayudó?