curl --request POST \
--url https://tudominio.com/webhooks/on-response \
--header 'Content-Type: application/json' \
--data '
{
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "1234",
"conversation_id": "5678",
"question": {
"type": "closed",
"text": "conversation-question-text",
"answers": [
{
"text": "answer-text"
}
]
},
"sent_at": "2019-01-01 00:00:00",
"responded_at": "2019-01-01 00:00:00",
"sent_text": "text-sent-to-user",
"actual_response": "Si necesito",
"classified_answer": {
"text": "answer-text"
},
"user_session_keys": [
{
"key": "name",
"value": "Juan",
"type": null
},
{
"key": "user_id",
"value": "12345",
"type": null
},
{
"key": "loc",
"value": "{\"latitude\": 4.5935443, \"longitude\": -72.0345404, \"address\": \"Carrera 7 #100-06\"}",
"type": "location"
}
]
}
'import requests
url = "https://tudominio.com/webhooks/on-response"
payload = {
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "1234",
"conversation_id": "5678",
"question": {
"type": "closed",
"text": "conversation-question-text",
"answers": [{ "text": "answer-text" }]
},
"sent_at": "2019-01-01 00:00:00",
"responded_at": "2019-01-01 00:00:00",
"sent_text": "text-sent-to-user",
"actual_response": "Si necesito",
"classified_answer": { "text": "answer-text" },
"user_session_keys": [
{
"key": "name",
"value": "Juan",
"type": None
},
{
"key": "user_id",
"value": "12345",
"type": None
},
{
"key": "loc",
"value": "{\"latitude\": 4.5935443, \"longitude\": -72.0345404, \"address\": \"Carrera 7 #100-06\"}",
"type": "location"
}
]
}
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: '1234',
conversation_id: '5678',
question: {
type: 'closed',
text: 'conversation-question-text',
answers: [{text: 'answer-text'}]
},
sent_at: '2019-01-01 00:00:00',
responded_at: '2019-01-01 00:00:00',
sent_text: 'text-sent-to-user',
actual_response: 'Si necesito',
classified_answer: {text: 'answer-text'},
user_session_keys: [
{key: 'name', value: 'Juan', type: null},
{key: 'user_id', value: '12345', type: null},
{
key: 'loc',
value: '{"latitude": 4.5935443, "longitude": -72.0345404, "address": "Carrera 7 #100-06"}',
type: 'location'
}
]
})
};
fetch('https://tudominio.com/webhooks/on-response', 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-response",
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' => '1234',
'conversation_id' => '5678',
'question' => [
'type' => 'closed',
'text' => 'conversation-question-text',
'answers' => [
[
'text' => 'answer-text'
]
]
],
'sent_at' => '2019-01-01 00:00:00',
'responded_at' => '2019-01-01 00:00:00',
'sent_text' => 'text-sent-to-user',
'actual_response' => 'Si necesito',
'classified_answer' => [
'text' => 'answer-text'
],
'user_session_keys' => [
[
'key' => 'name',
'value' => 'Juan',
'type' => null
],
[
'key' => 'user_id',
'value' => '12345',
'type' => null
],
[
'key' => 'loc',
'value' => '{"latitude": 4.5935443, "longitude": -72.0345404, "address": "Carrera 7 #100-06"}',
'type' => 'location'
]
]
]),
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-response"
payload := strings.NewReader("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"1234\",\n \"conversation_id\": \"5678\",\n \"question\": {\n \"type\": \"closed\",\n \"text\": \"conversation-question-text\",\n \"answers\": [\n {\n \"text\": \"answer-text\"\n }\n ]\n },\n \"sent_at\": \"2019-01-01 00:00:00\",\n \"responded_at\": \"2019-01-01 00:00:00\",\n \"sent_text\": \"text-sent-to-user\",\n \"actual_response\": \"Si necesito\",\n \"classified_answer\": {\n \"text\": \"answer-text\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"name\",\n \"value\": \"Juan\",\n \"type\": null\n },\n {\n \"key\": \"user_id\",\n \"value\": \"12345\",\n \"type\": null\n },\n {\n \"key\": \"loc\",\n \"value\": \"{\\\"latitude\\\": 4.5935443, \\\"longitude\\\": -72.0345404, \\\"address\\\": \\\"Carrera 7 #100-06\\\"}\",\n \"type\": \"location\"\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-response")
.header("Content-Type", "application/json")
.body("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"1234\",\n \"conversation_id\": \"5678\",\n \"question\": {\n \"type\": \"closed\",\n \"text\": \"conversation-question-text\",\n \"answers\": [\n {\n \"text\": \"answer-text\"\n }\n ]\n },\n \"sent_at\": \"2019-01-01 00:00:00\",\n \"responded_at\": \"2019-01-01 00:00:00\",\n \"sent_text\": \"text-sent-to-user\",\n \"actual_response\": \"Si necesito\",\n \"classified_answer\": {\n \"text\": \"answer-text\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"name\",\n \"value\": \"Juan\",\n \"type\": null\n },\n {\n \"key\": \"user_id\",\n \"value\": \"12345\",\n \"type\": null\n },\n {\n \"key\": \"loc\",\n \"value\": \"{\\\"latitude\\\": 4.5935443, \\\"longitude\\\": -72.0345404, \\\"address\\\": \\\"Carrera 7 #100-06\\\"}\",\n \"type\": \"location\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tudominio.com/webhooks/on-response")
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\": \"1234\",\n \"conversation_id\": \"5678\",\n \"question\": {\n \"type\": \"closed\",\n \"text\": \"conversation-question-text\",\n \"answers\": [\n {\n \"text\": \"answer-text\"\n }\n ]\n },\n \"sent_at\": \"2019-01-01 00:00:00\",\n \"responded_at\": \"2019-01-01 00:00:00\",\n \"sent_text\": \"text-sent-to-user\",\n \"actual_response\": \"Si necesito\",\n \"classified_answer\": {\n \"text\": \"answer-text\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"name\",\n \"value\": \"Juan\",\n \"type\": null\n },\n {\n \"key\": \"user_id\",\n \"value\": \"12345\",\n \"type\": null\n },\n {\n \"key\": \"loc\",\n \"value\": \"{\\\"latitude\\\": 4.5935443, \\\"longitude\\\": -72.0345404, \\\"address\\\": \\\"Carrera 7 #100-06\\\"}\",\n \"type\": \"location\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{}Cuerpo de la solicitud Webhook de respuesta de mensaje
Este endpoint debe ser implementado en TU servidor (por ejemplo: https://tudominio.com/webhooks/on-response). Treble llamará a este webhook cuando un usuario responda a una pregunta en la conversación. Debes configurar la URL de este webhook en el panel de administración de Treble.
curl --request POST \
--url https://tudominio.com/webhooks/on-response \
--header 'Content-Type: application/json' \
--data '
{
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "1234",
"conversation_id": "5678",
"question": {
"type": "closed",
"text": "conversation-question-text",
"answers": [
{
"text": "answer-text"
}
]
},
"sent_at": "2019-01-01 00:00:00",
"responded_at": "2019-01-01 00:00:00",
"sent_text": "text-sent-to-user",
"actual_response": "Si necesito",
"classified_answer": {
"text": "answer-text"
},
"user_session_keys": [
{
"key": "name",
"value": "Juan",
"type": null
},
{
"key": "user_id",
"value": "12345",
"type": null
},
{
"key": "loc",
"value": "{\"latitude\": 4.5935443, \"longitude\": -72.0345404, \"address\": \"Carrera 7 #100-06\"}",
"type": "location"
}
]
}
'import requests
url = "https://tudominio.com/webhooks/on-response"
payload = {
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "1234",
"conversation_id": "5678",
"question": {
"type": "closed",
"text": "conversation-question-text",
"answers": [{ "text": "answer-text" }]
},
"sent_at": "2019-01-01 00:00:00",
"responded_at": "2019-01-01 00:00:00",
"sent_text": "text-sent-to-user",
"actual_response": "Si necesito",
"classified_answer": { "text": "answer-text" },
"user_session_keys": [
{
"key": "name",
"value": "Juan",
"type": None
},
{
"key": "user_id",
"value": "12345",
"type": None
},
{
"key": "loc",
"value": "{\"latitude\": 4.5935443, \"longitude\": -72.0345404, \"address\": \"Carrera 7 #100-06\"}",
"type": "location"
}
]
}
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: '1234',
conversation_id: '5678',
question: {
type: 'closed',
text: 'conversation-question-text',
answers: [{text: 'answer-text'}]
},
sent_at: '2019-01-01 00:00:00',
responded_at: '2019-01-01 00:00:00',
sent_text: 'text-sent-to-user',
actual_response: 'Si necesito',
classified_answer: {text: 'answer-text'},
user_session_keys: [
{key: 'name', value: 'Juan', type: null},
{key: 'user_id', value: '12345', type: null},
{
key: 'loc',
value: '{"latitude": 4.5935443, "longitude": -72.0345404, "address": "Carrera 7 #100-06"}',
type: 'location'
}
]
})
};
fetch('https://tudominio.com/webhooks/on-response', 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-response",
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' => '1234',
'conversation_id' => '5678',
'question' => [
'type' => 'closed',
'text' => 'conversation-question-text',
'answers' => [
[
'text' => 'answer-text'
]
]
],
'sent_at' => '2019-01-01 00:00:00',
'responded_at' => '2019-01-01 00:00:00',
'sent_text' => 'text-sent-to-user',
'actual_response' => 'Si necesito',
'classified_answer' => [
'text' => 'answer-text'
],
'user_session_keys' => [
[
'key' => 'name',
'value' => 'Juan',
'type' => null
],
[
'key' => 'user_id',
'value' => '12345',
'type' => null
],
[
'key' => 'loc',
'value' => '{"latitude": 4.5935443, "longitude": -72.0345404, "address": "Carrera 7 #100-06"}',
'type' => 'location'
]
]
]),
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-response"
payload := strings.NewReader("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"1234\",\n \"conversation_id\": \"5678\",\n \"question\": {\n \"type\": \"closed\",\n \"text\": \"conversation-question-text\",\n \"answers\": [\n {\n \"text\": \"answer-text\"\n }\n ]\n },\n \"sent_at\": \"2019-01-01 00:00:00\",\n \"responded_at\": \"2019-01-01 00:00:00\",\n \"sent_text\": \"text-sent-to-user\",\n \"actual_response\": \"Si necesito\",\n \"classified_answer\": {\n \"text\": \"answer-text\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"name\",\n \"value\": \"Juan\",\n \"type\": null\n },\n {\n \"key\": \"user_id\",\n \"value\": \"12345\",\n \"type\": null\n },\n {\n \"key\": \"loc\",\n \"value\": \"{\\\"latitude\\\": 4.5935443, \\\"longitude\\\": -72.0345404, \\\"address\\\": \\\"Carrera 7 #100-06\\\"}\",\n \"type\": \"location\"\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-response")
.header("Content-Type", "application/json")
.body("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3161234567\",\n \"session_id\": \"1234\",\n \"conversation_id\": \"5678\",\n \"question\": {\n \"type\": \"closed\",\n \"text\": \"conversation-question-text\",\n \"answers\": [\n {\n \"text\": \"answer-text\"\n }\n ]\n },\n \"sent_at\": \"2019-01-01 00:00:00\",\n \"responded_at\": \"2019-01-01 00:00:00\",\n \"sent_text\": \"text-sent-to-user\",\n \"actual_response\": \"Si necesito\",\n \"classified_answer\": {\n \"text\": \"answer-text\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"name\",\n \"value\": \"Juan\",\n \"type\": null\n },\n {\n \"key\": \"user_id\",\n \"value\": \"12345\",\n \"type\": null\n },\n {\n \"key\": \"loc\",\n \"value\": \"{\\\"latitude\\\": 4.5935443, \\\"longitude\\\": -72.0345404, \\\"address\\\": \\\"Carrera 7 #100-06\\\"}\",\n \"type\": \"location\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tudominio.com/webhooks/on-response")
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\": \"1234\",\n \"conversation_id\": \"5678\",\n \"question\": {\n \"type\": \"closed\",\n \"text\": \"conversation-question-text\",\n \"answers\": [\n {\n \"text\": \"answer-text\"\n }\n ]\n },\n \"sent_at\": \"2019-01-01 00:00:00\",\n \"responded_at\": \"2019-01-01 00:00:00\",\n \"sent_text\": \"text-sent-to-user\",\n \"actual_response\": \"Si necesito\",\n \"classified_answer\": {\n \"text\": \"answer-text\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"name\",\n \"value\": \"Juan\",\n \"type\": null\n },\n {\n \"key\": \"user_id\",\n \"value\": \"12345\",\n \"type\": null\n },\n {\n \"key\": \"loc\",\n \"value\": \"{\\\"latitude\\\": 4.5935443, \\\"longitude\\\": -72.0345404, \\\"address\\\": \\\"Carrera 7 #100-06\\\"}\",\n \"type\": \"location\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{}Cuerpo
Información del evento de respuesta
Evento que se dispara cuando un usuario responde a una pregunta en la conversación
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
Show child attributes
Show child attributes
Fecha y hora en que se envió la pregunta
Fecha y hora en que el usuario respondió a la pregunta
Texto enviado al usuario
Respuesta literal proporcionada por el usuario
Respuesta clasificada basada en la respuesta del usuario
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
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ó?