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からWebフックイベントを受信し、WhatsAppにメッセージを送信します。 このURLをChatwoot受信トレイのWebhook設定で設定します。
CHATWOOT_WEBHOOK_SECRET が設定されている場合、リクエストはそのシークレットを知っていることを
証明する必要があります。 推奨:API チャンネルに Webhook シークレットが設定されている場合に Chatwoot が送信する、
Chatwoot 独自の署名を使用します。X-Chatwoot-Timestamp(Unix 秒)と
X-Chatwoot-Signature: sha256=<hex HMAC-SHA256 of "<timestamp>.<raw body>"> です。
タイムスタンプはサーバークロックのCHATWOOT_WEBHOOK_SIGNATURE_TOLERANCE (5m×
default) 内になければなりません。 次の形式も受け付けます:X-Hub-Signature-256
(生のリクエスト本文の HMAC-SHA256)、X-Chatwoot-Webhook-Secret
または X-Gowa-Chatwoot-Secret に指定したシークレット、あるいは secret クエリパラメーター(非推奨:
シークレットが URL やログに記録されるため)。
適用されるシークレットは、ペイロードのルーティング先デバイスのシークレットです。
そのデバイスの設定に webhook_secret がある場合はそれを使用します(この場合、
そのデバイスではグローバルシークレットは受け付けません)。それ以外の場合やデバイスを特定できない場合は、CHATWOOT_WEBHOOK_SECRET
を使用します。 許容時間内にすでに受け付けられた
(2xx を返した)Chatwoot 署名付きリクエストには、
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 Webhook ペイロード(Chatwoot documentationを参照)
レスポンス
Webhook処理完了
