curl --request POST \
--url http://localhost:3000/chatwoot/webhook \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "http://localhost:3000/chatwoot/webhook"
payload = {}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('http://localhost:3000/chatwoot/webhook', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3000",
CURLOPT_URL => "http://localhost:3000/chatwoot/webhook",
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([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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 := "http://localhost:3000/chatwoot/webhook"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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("http://localhost:3000/chatwoot/webhook")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3000/chatwoot/webhook")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"code": 400,
"message": "field cannot be blank",
"results": null
}Final de webhook de Chatwoot
Recibe eventos de webhook de Chatwoot y envía mensajes a WhatsApp. Configura esta URL en la configuración de tu buzón de entrada de Chatwoot.
Cuando CHATWOOT_WEBHOOK_SECRET está configurado, la solicitud debe probar el conocimiento de
. Recomendado: Firma propia de Chatwoot, enviado por Chatwoot cuando el canal API
tiene un secreto webhook — X-Chatwoot-Timestamp (unix seconds) y
X-Chatwoot-Signature: sha256=<hex HMAC-SHA256 of "<timestamp>.<raw body>">.
La marca de tiempo debe estar dentro de CHATWOOT_WEBHOOK_SIGNATURE_TOLERANCE (5m por omisión
) del reloj del servidor. También se aceptan: X-Hub-Signature-256
(HMAC-SHA256 del cuerpo sin procesar), el secreto en X-Chatwoot-Webhook-Secret
o X-Gowa-Chatwoot-Secret, o el parámetro de consulta secret (desaconsejado:
en ese caso, el secreto aparece en las URL y los registros).
El secreto que aplica es el secreto del dispositivo al que la carga útil es
enrutada a: el webhook_secret de la configuración de ese dispositivo cuando tiene uno (el secreto global
no es aceptado para ello), CHATWOOT_WEBHOOK_SECRET
de otro modo y cuando no se resuelva ningún dispositivo. Una solicitud firmada por Chatwoot de que
ya fue aceptada (respondida 2xx) dentro de la ventana de tolerancia es
reconocida con 200 y no actuada de nuevo. Una que fue respondida
con cualquier otro estado no se recuerda, así que enviar la solicitud idéntica
otra vez es tratada.
curl --request POST \
--url http://localhost:3000/chatwoot/webhook \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "http://localhost:3000/chatwoot/webhook"
payload = {}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('http://localhost:3000/chatwoot/webhook', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3000",
CURLOPT_URL => "http://localhost:3000/chatwoot/webhook",
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([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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 := "http://localhost:3000/chatwoot/webhook"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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("http://localhost:3000/chatwoot/webhook")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3000/chatwoot/webhook")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"code": 400,
"message": "field cannot be blank",
"results": null
}Autorizaciones
Encabezados
Parámetros de consulta
Cuerpo
Carga de webhook de Chatwoot (ver documentación de Chatwoot)
Respuesta
Webhook procesado
