curl --request POST \
--url https://seudominio.com/webhooks/on-agent-assignation \
--header 'Content-Type: application/json' \
--data '
{
"company_id": 1234,
"survey_user_id": 567890,
"contact": {
"treble_id": "5215512345678",
"name": "Andrea Soto",
"country_code": "52",
"cellphone": "5512345678",
"business_scope_id": "1029384756",
"username": null
},
"crm_type": "salesforce",
"crm_objects": [
{
"entity": "Contact",
"id": "0035f00000ABCDEqAO"
},
{
"entity": "Account",
"id": "0015f00000FGHIJqAO"
}
],
"channel": {
"phone_number_id": "1234567890"
},
"metadata": {
"poll_id": 4321,
"node_id": "a1b2c3",
"tag": "Comercial",
"language": "es"
}
}
'import requests
url = "https://seudominio.com/webhooks/on-agent-assignation"
payload = {
"company_id": 1234,
"survey_user_id": 567890,
"contact": {
"treble_id": "5215512345678",
"name": "Andrea Soto",
"country_code": "52",
"cellphone": "5512345678",
"business_scope_id": "1029384756",
"username": None
},
"crm_type": "salesforce",
"crm_objects": [
{
"entity": "Contact",
"id": "0035f00000ABCDEqAO"
},
{
"entity": "Account",
"id": "0015f00000FGHIJqAO"
}
],
"channel": { "phone_number_id": "1234567890" },
"metadata": {
"poll_id": 4321,
"node_id": "a1b2c3",
"tag": "Comercial",
"language": "es"
}
}
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({
company_id: 1234,
survey_user_id: 567890,
contact: {
treble_id: '5215512345678',
name: 'Andrea Soto',
country_code: '52',
cellphone: '5512345678',
business_scope_id: '1029384756',
username: null
},
crm_type: 'salesforce',
crm_objects: [
{entity: 'Contact', id: '0035f00000ABCDEqAO'},
{entity: 'Account', id: '0015f00000FGHIJqAO'}
],
channel: {phone_number_id: '1234567890'},
metadata: {poll_id: 4321, node_id: 'a1b2c3', tag: 'Comercial', language: 'es'}
})
};
fetch('https://seudominio.com/webhooks/on-agent-assignation', 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-agent-assignation",
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([
'company_id' => 1234,
'survey_user_id' => 567890,
'contact' => [
'treble_id' => '5215512345678',
'name' => 'Andrea Soto',
'country_code' => '52',
'cellphone' => '5512345678',
'business_scope_id' => '1029384756',
'username' => null
],
'crm_type' => 'salesforce',
'crm_objects' => [
[
'entity' => 'Contact',
'id' => '0035f00000ABCDEqAO'
],
[
'entity' => 'Account',
'id' => '0015f00000FGHIJqAO'
]
],
'channel' => [
'phone_number_id' => '1234567890'
],
'metadata' => [
'poll_id' => 4321,
'node_id' => 'a1b2c3',
'tag' => 'Comercial',
'language' => 'es'
]
]),
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-agent-assignation"
payload := strings.NewReader("{\n \"company_id\": 1234,\n \"survey_user_id\": 567890,\n \"contact\": {\n \"treble_id\": \"5215512345678\",\n \"name\": \"Andrea Soto\",\n \"country_code\": \"52\",\n \"cellphone\": \"5512345678\",\n \"business_scope_id\": \"1029384756\",\n \"username\": null\n },\n \"crm_type\": \"salesforce\",\n \"crm_objects\": [\n {\n \"entity\": \"Contact\",\n \"id\": \"0035f00000ABCDEqAO\"\n },\n {\n \"entity\": \"Account\",\n \"id\": \"0015f00000FGHIJqAO\"\n }\n ],\n \"channel\": {\n \"phone_number_id\": \"1234567890\"\n },\n \"metadata\": {\n \"poll_id\": 4321,\n \"node_id\": \"a1b2c3\",\n \"tag\": \"Comercial\",\n \"language\": \"es\"\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-agent-assignation")
.header("Content-Type", "application/json")
.body("{\n \"company_id\": 1234,\n \"survey_user_id\": 567890,\n \"contact\": {\n \"treble_id\": \"5215512345678\",\n \"name\": \"Andrea Soto\",\n \"country_code\": \"52\",\n \"cellphone\": \"5512345678\",\n \"business_scope_id\": \"1029384756\",\n \"username\": null\n },\n \"crm_type\": \"salesforce\",\n \"crm_objects\": [\n {\n \"entity\": \"Contact\",\n \"id\": \"0035f00000ABCDEqAO\"\n },\n {\n \"entity\": \"Account\",\n \"id\": \"0015f00000FGHIJqAO\"\n }\n ],\n \"channel\": {\n \"phone_number_id\": \"1234567890\"\n },\n \"metadata\": {\n \"poll_id\": 4321,\n \"node_id\": \"a1b2c3\",\n \"tag\": \"Comercial\",\n \"language\": \"es\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://seudominio.com/webhooks/on-agent-assignation")
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 \"company_id\": 1234,\n \"survey_user_id\": 567890,\n \"contact\": {\n \"treble_id\": \"5215512345678\",\n \"name\": \"Andrea Soto\",\n \"country_code\": \"52\",\n \"cellphone\": \"5512345678\",\n \"business_scope_id\": \"1029384756\",\n \"username\": null\n },\n \"crm_type\": \"salesforce\",\n \"crm_objects\": [\n {\n \"entity\": \"Contact\",\n \"id\": \"0035f00000ABCDEqAO\"\n },\n {\n \"entity\": \"Account\",\n \"id\": \"0015f00000FGHIJqAO\"\n }\n ],\n \"channel\": {\n \"phone_number_id\": \"1234567890\"\n },\n \"metadata\": {\n \"poll_id\": 4321,\n \"node_id\": \"a1b2c3\",\n \"tag\": \"Comercial\",\n \"language\": \"es\"\n }\n}"
response = http.request(request)
puts response.read_body{
"agent_id": 4567
}Referência do webhook de atribuição
Este endpoint deve ser implementado no SEU servidor (por exemplo: https://seudominio.com/webhooks/on-agent-assignation). O Treble o chamará quando uma conversa chegar a um bloco de Métodos de transferência configurado com o destino API, para que o seu sistema decida qual agente deve receber o chat.
A URL é configurada no próprio bloco, dentro do editor de conversas. Se você ativar a autenticação por Token / API Key, o Treble incluirá o seu token no header Authorization com o formato Bearer SEU_TOKEN.
Você deve responder em menos de 10 segundos. Se o seu servidor não responder a tempo, devolver um código diferente de 200, ou devolver um agente que não pode receber a conversa, o Treble aplicará o método de reserva configurado na plataforma principal.
curl --request POST \
--url https://seudominio.com/webhooks/on-agent-assignation \
--header 'Content-Type: application/json' \
--data '
{
"company_id": 1234,
"survey_user_id": 567890,
"contact": {
"treble_id": "5215512345678",
"name": "Andrea Soto",
"country_code": "52",
"cellphone": "5512345678",
"business_scope_id": "1029384756",
"username": null
},
"crm_type": "salesforce",
"crm_objects": [
{
"entity": "Contact",
"id": "0035f00000ABCDEqAO"
},
{
"entity": "Account",
"id": "0015f00000FGHIJqAO"
}
],
"channel": {
"phone_number_id": "1234567890"
},
"metadata": {
"poll_id": 4321,
"node_id": "a1b2c3",
"tag": "Comercial",
"language": "es"
}
}
'import requests
url = "https://seudominio.com/webhooks/on-agent-assignation"
payload = {
"company_id": 1234,
"survey_user_id": 567890,
"contact": {
"treble_id": "5215512345678",
"name": "Andrea Soto",
"country_code": "52",
"cellphone": "5512345678",
"business_scope_id": "1029384756",
"username": None
},
"crm_type": "salesforce",
"crm_objects": [
{
"entity": "Contact",
"id": "0035f00000ABCDEqAO"
},
{
"entity": "Account",
"id": "0015f00000FGHIJqAO"
}
],
"channel": { "phone_number_id": "1234567890" },
"metadata": {
"poll_id": 4321,
"node_id": "a1b2c3",
"tag": "Comercial",
"language": "es"
}
}
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({
company_id: 1234,
survey_user_id: 567890,
contact: {
treble_id: '5215512345678',
name: 'Andrea Soto',
country_code: '52',
cellphone: '5512345678',
business_scope_id: '1029384756',
username: null
},
crm_type: 'salesforce',
crm_objects: [
{entity: 'Contact', id: '0035f00000ABCDEqAO'},
{entity: 'Account', id: '0015f00000FGHIJqAO'}
],
channel: {phone_number_id: '1234567890'},
metadata: {poll_id: 4321, node_id: 'a1b2c3', tag: 'Comercial', language: 'es'}
})
};
fetch('https://seudominio.com/webhooks/on-agent-assignation', 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-agent-assignation",
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([
'company_id' => 1234,
'survey_user_id' => 567890,
'contact' => [
'treble_id' => '5215512345678',
'name' => 'Andrea Soto',
'country_code' => '52',
'cellphone' => '5512345678',
'business_scope_id' => '1029384756',
'username' => null
],
'crm_type' => 'salesforce',
'crm_objects' => [
[
'entity' => 'Contact',
'id' => '0035f00000ABCDEqAO'
],
[
'entity' => 'Account',
'id' => '0015f00000FGHIJqAO'
]
],
'channel' => [
'phone_number_id' => '1234567890'
],
'metadata' => [
'poll_id' => 4321,
'node_id' => 'a1b2c3',
'tag' => 'Comercial',
'language' => 'es'
]
]),
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-agent-assignation"
payload := strings.NewReader("{\n \"company_id\": 1234,\n \"survey_user_id\": 567890,\n \"contact\": {\n \"treble_id\": \"5215512345678\",\n \"name\": \"Andrea Soto\",\n \"country_code\": \"52\",\n \"cellphone\": \"5512345678\",\n \"business_scope_id\": \"1029384756\",\n \"username\": null\n },\n \"crm_type\": \"salesforce\",\n \"crm_objects\": [\n {\n \"entity\": \"Contact\",\n \"id\": \"0035f00000ABCDEqAO\"\n },\n {\n \"entity\": \"Account\",\n \"id\": \"0015f00000FGHIJqAO\"\n }\n ],\n \"channel\": {\n \"phone_number_id\": \"1234567890\"\n },\n \"metadata\": {\n \"poll_id\": 4321,\n \"node_id\": \"a1b2c3\",\n \"tag\": \"Comercial\",\n \"language\": \"es\"\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-agent-assignation")
.header("Content-Type", "application/json")
.body("{\n \"company_id\": 1234,\n \"survey_user_id\": 567890,\n \"contact\": {\n \"treble_id\": \"5215512345678\",\n \"name\": \"Andrea Soto\",\n \"country_code\": \"52\",\n \"cellphone\": \"5512345678\",\n \"business_scope_id\": \"1029384756\",\n \"username\": null\n },\n \"crm_type\": \"salesforce\",\n \"crm_objects\": [\n {\n \"entity\": \"Contact\",\n \"id\": \"0035f00000ABCDEqAO\"\n },\n {\n \"entity\": \"Account\",\n \"id\": \"0015f00000FGHIJqAO\"\n }\n ],\n \"channel\": {\n \"phone_number_id\": \"1234567890\"\n },\n \"metadata\": {\n \"poll_id\": 4321,\n \"node_id\": \"a1b2c3\",\n \"tag\": \"Comercial\",\n \"language\": \"es\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://seudominio.com/webhooks/on-agent-assignation")
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 \"company_id\": 1234,\n \"survey_user_id\": 567890,\n \"contact\": {\n \"treble_id\": \"5215512345678\",\n \"name\": \"Andrea Soto\",\n \"country_code\": \"52\",\n \"cellphone\": \"5512345678\",\n \"business_scope_id\": \"1029384756\",\n \"username\": null\n },\n \"crm_type\": \"salesforce\",\n \"crm_objects\": [\n {\n \"entity\": \"Contact\",\n \"id\": \"0035f00000ABCDEqAO\"\n },\n {\n \"entity\": \"Account\",\n \"id\": \"0015f00000FGHIJqAO\"\n }\n ],\n \"channel\": {\n \"phone_number_id\": \"1234567890\"\n },\n \"metadata\": {\n \"poll_id\": 4321,\n \"node_id\": \"a1b2c3\",\n \"tag\": \"Comercial\",\n \"language\": \"es\"\n }\n}"
response = http.request(request)
puts response.read_body{
"agent_id": 4567
}Cabeçalhos
Apenas se você configurou autenticação por Token / API Key no bloco. O Treble envia o token com o formato Bearer SEU_TOKEN.
Corpo
Contexto do contato e da conversa que o Treble envia ao seu endpoint
Corpo que o Treble envia ao seu endpoint para que você decida qual agente recebe a conversa.
Identificador da sua empresa no Treble.
1234
Identificador da sessão do contato na conversa.
567890
Informações do contato que está na conversa.
Show child attributes
Show child attributes
CRM com o qual a sua conta está integrada, por exemplo salesforce ou hubspot. É null se a conta não tiver integração de CRM.
"salesforce"
Registros do CRM associados ao contato. Um array vazio significa que o contato ainda não está associado a nenhum registro.
Show child attributes
Show child attributes
Canal pelo qual a conversa entrou.
Show child attributes
Show child attributes
Contexto do fluxo e do bloco que originou a chamada.
Show child attributes
Show child attributes
Resposta
Agente ao qual o Treble deve atribuir a conversa. Devolva agent_id (recomendado) ou agent_email.
Resposta que o seu servidor deve devolver indicando o agente que receberá a conversa. Use agent_id ou agent_email.
Identificador do agente no Treble. É a opção recomendada: é um identificador estável que nunca muda, mesmo se o email do agente for atualizado.
4567
Email do agente, exatamente como está registrado no Treble. Também é suportado; se você enviar ambos os campos, agent_email tem precedência.
"andrea.soto@suaempresa.com"
Esta página foi útil?