curl --request POST \
--url https://seudominio.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": "texto-da-pergunta-da-conversa",
"answers": [
{
"text": "texto-da-resposta"
}
]
},
"sent_at": "2019-01-01 00:00:00",
"responded_at": "2019-01-01 00:00:00",
"sent_text": "texto-enviado-ao-usuário",
"actual_response": "Sim, preciso",
"classified_answer": {
"text": "texto-da-resposta"
},
"user_session_keys": [
{
"key": "name",
"value": "João",
"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://seudominio.com/webhooks/on-response"
payload = {
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "1234",
"conversation_id": "5678",
"question": {
"type": "closed",
"text": "texto-da-pergunta-da-conversa",
"answers": [{ "text": "texto-da-resposta" }]
},
"sent_at": "2019-01-01 00:00:00",
"responded_at": "2019-01-01 00:00:00",
"sent_text": "texto-enviado-ao-usuário",
"actual_response": "Sim, preciso",
"classified_answer": { "text": "texto-da-resposta" },
"user_session_keys": [
{
"key": "name",
"value": "João",
"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: 'texto-da-pergunta-da-conversa',
answers: [{text: 'texto-da-resposta'}]
},
sent_at: '2019-01-01 00:00:00',
responded_at: '2019-01-01 00:00:00',
sent_text: 'texto-enviado-ao-usuário',
actual_response: 'Sim, preciso',
classified_answer: {text: 'texto-da-resposta'},
user_session_keys: [
{key: 'name', value: 'João', 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://seudominio.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://seudominio.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' => 'texto-da-pergunta-da-conversa',
'answers' => [
[
'text' => 'texto-da-resposta'
]
]
],
'sent_at' => '2019-01-01 00:00:00',
'responded_at' => '2019-01-01 00:00:00',
'sent_text' => 'texto-enviado-ao-usuário',
'actual_response' => 'Sim, preciso',
'classified_answer' => [
'text' => 'texto-da-resposta'
],
'user_session_keys' => [
[
'key' => 'name',
'value' => 'João',
'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://seudominio.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\": \"texto-da-pergunta-da-conversa\",\n \"answers\": [\n {\n \"text\": \"texto-da-resposta\"\n }\n ]\n },\n \"sent_at\": \"2019-01-01 00:00:00\",\n \"responded_at\": \"2019-01-01 00:00:00\",\n \"sent_text\": \"texto-enviado-ao-usuário\",\n \"actual_response\": \"Sim, preciso\",\n \"classified_answer\": {\n \"text\": \"texto-da-resposta\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"name\",\n \"value\": \"João\",\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://seudominio.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\": \"texto-da-pergunta-da-conversa\",\n \"answers\": [\n {\n \"text\": \"texto-da-resposta\"\n }\n ]\n },\n \"sent_at\": \"2019-01-01 00:00:00\",\n \"responded_at\": \"2019-01-01 00:00:00\",\n \"sent_text\": \"texto-enviado-ao-usuário\",\n \"actual_response\": \"Sim, preciso\",\n \"classified_answer\": {\n \"text\": \"texto-da-resposta\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"name\",\n \"value\": \"João\",\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://seudominio.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\": \"texto-da-pergunta-da-conversa\",\n \"answers\": [\n {\n \"text\": \"texto-da-resposta\"\n }\n ]\n },\n \"sent_at\": \"2019-01-01 00:00:00\",\n \"responded_at\": \"2019-01-01 00:00:00\",\n \"sent_text\": \"texto-enviado-ao-usuário\",\n \"actual_response\": \"Sim, preciso\",\n \"classified_answer\": {\n \"text\": \"texto-da-resposta\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"name\",\n \"value\": \"João\",\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{}Corpo da Solicitação Webhook de Resposta de Mensagem
Este endpoint deve ser implementado no SEU servidor (por exemplo: https://seudominio.com/webhooks/on-response). O Treble chamará este webhook quando um usuário responder a uma pergunta 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-response \
--header 'Content-Type: application/json' \
--data '
{
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "1234",
"conversation_id": "5678",
"question": {
"type": "closed",
"text": "texto-da-pergunta-da-conversa",
"answers": [
{
"text": "texto-da-resposta"
}
]
},
"sent_at": "2019-01-01 00:00:00",
"responded_at": "2019-01-01 00:00:00",
"sent_text": "texto-enviado-ao-usuário",
"actual_response": "Sim, preciso",
"classified_answer": {
"text": "texto-da-resposta"
},
"user_session_keys": [
{
"key": "name",
"value": "João",
"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://seudominio.com/webhooks/on-response"
payload = {
"country_code": "+57",
"cellphone": "3161234567",
"session_id": "1234",
"conversation_id": "5678",
"question": {
"type": "closed",
"text": "texto-da-pergunta-da-conversa",
"answers": [{ "text": "texto-da-resposta" }]
},
"sent_at": "2019-01-01 00:00:00",
"responded_at": "2019-01-01 00:00:00",
"sent_text": "texto-enviado-ao-usuário",
"actual_response": "Sim, preciso",
"classified_answer": { "text": "texto-da-resposta" },
"user_session_keys": [
{
"key": "name",
"value": "João",
"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: 'texto-da-pergunta-da-conversa',
answers: [{text: 'texto-da-resposta'}]
},
sent_at: '2019-01-01 00:00:00',
responded_at: '2019-01-01 00:00:00',
sent_text: 'texto-enviado-ao-usuário',
actual_response: 'Sim, preciso',
classified_answer: {text: 'texto-da-resposta'},
user_session_keys: [
{key: 'name', value: 'João', 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://seudominio.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://seudominio.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' => 'texto-da-pergunta-da-conversa',
'answers' => [
[
'text' => 'texto-da-resposta'
]
]
],
'sent_at' => '2019-01-01 00:00:00',
'responded_at' => '2019-01-01 00:00:00',
'sent_text' => 'texto-enviado-ao-usuário',
'actual_response' => 'Sim, preciso',
'classified_answer' => [
'text' => 'texto-da-resposta'
],
'user_session_keys' => [
[
'key' => 'name',
'value' => 'João',
'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://seudominio.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\": \"texto-da-pergunta-da-conversa\",\n \"answers\": [\n {\n \"text\": \"texto-da-resposta\"\n }\n ]\n },\n \"sent_at\": \"2019-01-01 00:00:00\",\n \"responded_at\": \"2019-01-01 00:00:00\",\n \"sent_text\": \"texto-enviado-ao-usuário\",\n \"actual_response\": \"Sim, preciso\",\n \"classified_answer\": {\n \"text\": \"texto-da-resposta\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"name\",\n \"value\": \"João\",\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://seudominio.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\": \"texto-da-pergunta-da-conversa\",\n \"answers\": [\n {\n \"text\": \"texto-da-resposta\"\n }\n ]\n },\n \"sent_at\": \"2019-01-01 00:00:00\",\n \"responded_at\": \"2019-01-01 00:00:00\",\n \"sent_text\": \"texto-enviado-ao-usuário\",\n \"actual_response\": \"Sim, preciso\",\n \"classified_answer\": {\n \"text\": \"texto-da-resposta\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"name\",\n \"value\": \"João\",\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://seudominio.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\": \"texto-da-pergunta-da-conversa\",\n \"answers\": [\n {\n \"text\": \"texto-da-resposta\"\n }\n ]\n },\n \"sent_at\": \"2019-01-01 00:00:00\",\n \"responded_at\": \"2019-01-01 00:00:00\",\n \"sent_text\": \"texto-enviado-ao-usuário\",\n \"actual_response\": \"Sim, preciso\",\n \"classified_answer\": {\n \"text\": \"texto-da-resposta\"\n },\n \"user_session_keys\": [\n {\n \"key\": \"name\",\n \"value\": \"João\",\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{}Corpo
Informações do evento de resposta
Evento que é disparado quando um usuário responde a uma pergunta na conversa
Código do país do usuário
Número de telefone do usuário sem o código do país
ID da sessão do usuário
ID da conversa
Show child attributes
Show child attributes
Data e hora em que a pergunta foi enviada
Data e hora em que o usuário respondeu à pergunta
Texto enviado ao usuário
Resposta literal fornecida pelo usuário
Resposta classificada baseada na resposta do usuário
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?