curl --request POST \
--url https://yourdomain.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://yourdomain.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://yourdomain.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://yourdomain.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://yourdomain.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://yourdomain.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://yourdomain.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 Webhook Request Body (Alternate Flow)
This endpoint must be implemented on YOUR server (e.g., https://yourdomain.com/webhooks/on-timeout). Treble will call this webhook when a timeout occurs in the conversation (the user does not respond within the established time). You must configure the URL of this webhook in the Treble admin panel.
curl --request POST \
--url https://yourdomain.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://yourdomain.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://yourdomain.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://yourdomain.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://yourdomain.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://yourdomain.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://yourdomain.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.Body
Information of the timeout event
Event that is triggered when a timeout occurs in the conversation (the user does not respond within the established time)
Country code of the user
User's phone number without the country code
ID of the user's session
ID of the conversation
Question that did not receive a response in time
Show child attributes
Show child attributes
Date and time when the timeout occurred
User session keys collected during the conversation or provided during the deployment
Show child attributes
Show child attributes
Response
Response to update or add information to the session
JSON object with the new information that will be replaced or added to the session for future use. The service must respond in less than 10 seconds.
Was this page helpful?