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
}نقطة نهاية Chatwoot
يستقبل أحداث webhook من Chatwoot ويرسل رسائل إلى WhatsApp. تكوين هذا الرابط في إعدادات صندوق البريد الوارد الخاص بك في Chatwoot.
عند تعيين CHATWOOT_WEBHOOK_SECRET يجب أن يثبت الطلب علمه بـ
الموصى به: توقيع Chatwoot نفسه، الذي يرسله Chatwoot عندما تكون لقناة API
قيمة سرية للـ webhook — X-Chatwoot-Timestamp (بالثواني منذ بداية حقبة Unix) و
X-Chatwoot-Signature: sha256=<hex HMAC-SHA256 of "<timestamp>.<raw body>">.
يجب أن يكون الطابع الزمني داخل CHATWOOT_WEBHOOK_SIGNATURE_TOLERANCE (5m من
الافتراضي) لساعة الخادم. يُقبَل أيضًا: X-Hub-Signature-256
(قيمة HMAC-SHA256 لمحتوى الطلب الخام)، أو القيمة السرية في X-Chatwoot-Webhook-Secret
أو X-Gowa-Chatwoot-Secret، أو معامل الاستعلام secret (لا يُنصح به:
إذ تظهر القيمة السرية عندئذ في عناوين URL والسجلات).
السر الذي ينطبق هو سر الجهاز الذي تحمله هو
موجه إلى: إعدادات الجهاز webhook_secret عندما يكون لديه واحد (أسرار
العالمية غير مقبولة لها)، CHATWOOT_WEBHOOK_SECRET
خلاف ذلك وعندما لا يحل أي جهاز. طلب توقيع Chatwoooo الذي تم قبوله بالفعل
(تمت الإجابة على 2xx) داخل نافذة التسامح هو
تم إقراره بـ 200 ولم يتم اتخاذ إجراء بشأنه مرة أخرى. لا نتذكر واحدة تمت الإجابة عليها
مع أي حالة أخرى، لذا يتم معالجة الطلب
المتطابق مرة أخرى.
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
}التفويضات
الترويسات
الجسم
حمولة ويب هوك Chatwoot (انظر وثائق Chatwoot)
الاستجابة
تم معالجة Webhook
