curl --request POST \
--url https://yourdomain.com/webhooks/on-optout \
--header 'Content-Type: application/json' \
--data '
{
"country_code": "+57",
"cellphone": "3176477608",
"session_id": "85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8",
"conversation_id": 54263,
"question": {
"type": "closed",
"text": "Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. ",
"answers": [
{
"text": "Sure"
},
{
"text": "No, thanks"
},
{
"text": "DEFAULT"
}
]
},
"sent_at": "2021-10-22 00:15:39.044704",
"sent_text": "Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \n1) Sure\n2) No, thanks\n3) DEFAULT",
"user_session_keys": [],
"classified_answer": {
"text": "No, thanks"
},
"reason": "OPTOUT"
}
'import requests
url = "https://yourdomain.com/webhooks/on-optout"
payload = {
"country_code": "+57",
"cellphone": "3176477608",
"session_id": "85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8",
"conversation_id": 54263,
"question": {
"type": "closed",
"text": "Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. ",
"answers": [{ "text": "Sure" }, { "text": "No, thanks" }, { "text": "DEFAULT" }]
},
"sent_at": "2021-10-22 00:15:39.044704",
"sent_text": "Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that.
1) Sure
2) No, thanks
3) DEFAULT",
"user_session_keys": [],
"classified_answer": { "text": "No, thanks" },
"reason": "OPTOUT"
}
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: '3176477608',
session_id: '85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8',
conversation_id: 54263,
question: {
type: 'closed',
text: 'Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. ',
answers: [{text: 'Sure'}, {text: 'No, thanks'}, {text: 'DEFAULT'}]
},
sent_at: '2021-10-22 00:15:39.044704',
sent_text: 'Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \n1) Sure\n2) No, thanks\n3) DEFAULT',
user_session_keys: [],
classified_answer: {text: 'No, thanks'},
reason: 'OPTOUT'
})
};
fetch('https://yourdomain.com/webhooks/on-optout', 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-optout",
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' => '3176477608',
'session_id' => '85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8',
'conversation_id' => 54263,
'question' => [
'type' => 'closed',
'text' => 'Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. ',
'answers' => [
[
'text' => 'Sure'
],
[
'text' => 'No, thanks'
],
[
'text' => 'DEFAULT'
]
]
],
'sent_at' => '2021-10-22 00:15:39.044704',
'sent_text' => 'Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that.
1) Sure
2) No, thanks
3) DEFAULT',
'user_session_keys' => [
],
'classified_answer' => [
'text' => 'No, thanks'
],
'reason' => 'OPTOUT'
]),
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-optout"
payload := strings.NewReader("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3176477608\",\n \"session_id\": \"85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8\",\n \"conversation_id\": 54263,\n \"question\": {\n \"type\": \"closed\",\n \"text\": \"Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \",\n \"answers\": [\n {\n \"text\": \"Sure\"\n },\n {\n \"text\": \"No, thanks\"\n },\n {\n \"text\": \"DEFAULT\"\n }\n ]\n },\n \"sent_at\": \"2021-10-22 00:15:39.044704\",\n \"sent_text\": \"Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \\n1) Sure\\n2) No, thanks\\n3) DEFAULT\",\n \"user_session_keys\": [],\n \"classified_answer\": {\n \"text\": \"No, thanks\"\n },\n \"reason\": \"OPTOUT\"\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-optout")
.header("Content-Type", "application/json")
.body("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3176477608\",\n \"session_id\": \"85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8\",\n \"conversation_id\": 54263,\n \"question\": {\n \"type\": \"closed\",\n \"text\": \"Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \",\n \"answers\": [\n {\n \"text\": \"Sure\"\n },\n {\n \"text\": \"No, thanks\"\n },\n {\n \"text\": \"DEFAULT\"\n }\n ]\n },\n \"sent_at\": \"2021-10-22 00:15:39.044704\",\n \"sent_text\": \"Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \\n1) Sure\\n2) No, thanks\\n3) DEFAULT\",\n \"user_session_keys\": [],\n \"classified_answer\": {\n \"text\": \"No, thanks\"\n },\n \"reason\": \"OPTOUT\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://yourdomain.com/webhooks/on-optout")
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\": \"3176477608\",\n \"session_id\": \"85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8\",\n \"conversation_id\": 54263,\n \"question\": {\n \"type\": \"closed\",\n \"text\": \"Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \",\n \"answers\": [\n {\n \"text\": \"Sure\"\n },\n {\n \"text\": \"No, thanks\"\n },\n {\n \"text\": \"DEFAULT\"\n }\n ]\n },\n \"sent_at\": \"2021-10-22 00:15:39.044704\",\n \"sent_text\": \"Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \\n1) Sure\\n2) No, thanks\\n3) DEFAULT\",\n \"user_session_keys\": [],\n \"classified_answer\": {\n \"text\": \"No, thanks\"\n },\n \"reason\": \"OPTOUT\"\n}"
response = http.request(request)
puts response.read_body{}Opt-out Webhook Request Body
This endpoint must be implemented on YOUR server (e.g., https://yourdomain.com/webhooks/on-optout). Treble will call this webhook when a user decides to opt out or exit the conversation. You must configure the URL of this webhook in the Treble admin panel.
curl --request POST \
--url https://yourdomain.com/webhooks/on-optout \
--header 'Content-Type: application/json' \
--data '
{
"country_code": "+57",
"cellphone": "3176477608",
"session_id": "85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8",
"conversation_id": 54263,
"question": {
"type": "closed",
"text": "Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. ",
"answers": [
{
"text": "Sure"
},
{
"text": "No, thanks"
},
{
"text": "DEFAULT"
}
]
},
"sent_at": "2021-10-22 00:15:39.044704",
"sent_text": "Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \n1) Sure\n2) No, thanks\n3) DEFAULT",
"user_session_keys": [],
"classified_answer": {
"text": "No, thanks"
},
"reason": "OPTOUT"
}
'import requests
url = "https://yourdomain.com/webhooks/on-optout"
payload = {
"country_code": "+57",
"cellphone": "3176477608",
"session_id": "85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8",
"conversation_id": 54263,
"question": {
"type": "closed",
"text": "Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. ",
"answers": [{ "text": "Sure" }, { "text": "No, thanks" }, { "text": "DEFAULT" }]
},
"sent_at": "2021-10-22 00:15:39.044704",
"sent_text": "Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that.
1) Sure
2) No, thanks
3) DEFAULT",
"user_session_keys": [],
"classified_answer": { "text": "No, thanks" },
"reason": "OPTOUT"
}
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: '3176477608',
session_id: '85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8',
conversation_id: 54263,
question: {
type: 'closed',
text: 'Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. ',
answers: [{text: 'Sure'}, {text: 'No, thanks'}, {text: 'DEFAULT'}]
},
sent_at: '2021-10-22 00:15:39.044704',
sent_text: 'Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \n1) Sure\n2) No, thanks\n3) DEFAULT',
user_session_keys: [],
classified_answer: {text: 'No, thanks'},
reason: 'OPTOUT'
})
};
fetch('https://yourdomain.com/webhooks/on-optout', 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-optout",
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' => '3176477608',
'session_id' => '85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8',
'conversation_id' => 54263,
'question' => [
'type' => 'closed',
'text' => 'Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. ',
'answers' => [
[
'text' => 'Sure'
],
[
'text' => 'No, thanks'
],
[
'text' => 'DEFAULT'
]
]
],
'sent_at' => '2021-10-22 00:15:39.044704',
'sent_text' => 'Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that.
1) Sure
2) No, thanks
3) DEFAULT',
'user_session_keys' => [
],
'classified_answer' => [
'text' => 'No, thanks'
],
'reason' => 'OPTOUT'
]),
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-optout"
payload := strings.NewReader("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3176477608\",\n \"session_id\": \"85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8\",\n \"conversation_id\": 54263,\n \"question\": {\n \"type\": \"closed\",\n \"text\": \"Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \",\n \"answers\": [\n {\n \"text\": \"Sure\"\n },\n {\n \"text\": \"No, thanks\"\n },\n {\n \"text\": \"DEFAULT\"\n }\n ]\n },\n \"sent_at\": \"2021-10-22 00:15:39.044704\",\n \"sent_text\": \"Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \\n1) Sure\\n2) No, thanks\\n3) DEFAULT\",\n \"user_session_keys\": [],\n \"classified_answer\": {\n \"text\": \"No, thanks\"\n },\n \"reason\": \"OPTOUT\"\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-optout")
.header("Content-Type", "application/json")
.body("{\n \"country_code\": \"+57\",\n \"cellphone\": \"3176477608\",\n \"session_id\": \"85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8\",\n \"conversation_id\": 54263,\n \"question\": {\n \"type\": \"closed\",\n \"text\": \"Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \",\n \"answers\": [\n {\n \"text\": \"Sure\"\n },\n {\n \"text\": \"No, thanks\"\n },\n {\n \"text\": \"DEFAULT\"\n }\n ]\n },\n \"sent_at\": \"2021-10-22 00:15:39.044704\",\n \"sent_text\": \"Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \\n1) Sure\\n2) No, thanks\\n3) DEFAULT\",\n \"user_session_keys\": [],\n \"classified_answer\": {\n \"text\": \"No, thanks\"\n },\n \"reason\": \"OPTOUT\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://yourdomain.com/webhooks/on-optout")
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\": \"3176477608\",\n \"session_id\": \"85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8\",\n \"conversation_id\": 54263,\n \"question\": {\n \"type\": \"closed\",\n \"text\": \"Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \",\n \"answers\": [\n {\n \"text\": \"Sure\"\n },\n {\n \"text\": \"No, thanks\"\n },\n {\n \"text\": \"DEFAULT\"\n }\n ]\n },\n \"sent_at\": \"2021-10-22 00:15:39.044704\",\n \"sent_text\": \"Hi! Thanks for attending our webinar today. We would like to have a feedback about our session and we would be very grateful if you could help us with that. \\n1) Sure\\n2) No, thanks\\n3) DEFAULT\",\n \"user_session_keys\": [],\n \"classified_answer\": {\n \"text\": \"No, thanks\"\n },\n \"reason\": \"OPTOUT\"\n}"
response = http.request(request)
puts response.read_body{}Body
Information of the opt-out event
Event that is triggered when a user decides to opt out or exit the conversation
Country code of the user
User's phone number without the country code
ID of the user's session
ID of the conversation
Show child attributes
Show child attributes
Date and time when the question was sent
Text sent to the user
Classified answer based on the user's response
Show child attributes
Show child attributes
Reason for the user's exit, in this case 'OPTOUT' to indicate that the user decided to opt out
OPTOUT 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?