Channel Webhooks
Post user message from a REST channel
Post a message from the user and forward it to the assistant. Return the message of the assistant to the user.
POST
/
webhooks
/
{rest_channel}
/
webhook
Post user message from a REST channel
curl --request POST \
--url 'http://localhost:5005/webhooks/{rest_channel}/webhook?token=' \
--header 'Content-Type: application/json' \
--data '
{
"sender": "default",
"message": "Hello!"
}
'import requests
url = "http://localhost:5005/webhooks/{rest_channel}/webhook?token="
payload = {
"sender": "default",
"message": "Hello!"
}
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({sender: 'default', message: 'Hello!'})
};
fetch('http://localhost:5005/webhooks/{rest_channel}/webhook?token=', 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 => "5005",
CURLOPT_URL => "http://localhost:5005/webhooks/{rest_channel}/webhook?token=",
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([
'sender' => 'default',
'message' => 'Hello!'
]),
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 := "http://localhost:5005/webhooks/{rest_channel}/webhook?token="
payload := strings.NewReader("{\n \"sender\": \"default\",\n \"message\": \"Hello!\"\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("http://localhost:5005/webhooks/{rest_channel}/webhook?token=")
.header("Content-Type", "application/json")
.body("{\n \"sender\": \"default\",\n \"message\": \"Hello!\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:5005/webhooks/{rest_channel}/webhook?token=")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"sender\": \"default\",\n \"message\": \"Hello!\"\n}"
response = http.request(request)
puts response.read_body[
{
"recipient_id": "default",
"text": "Hello!"
}
]{
"version": "1.0.0",
"status": "failure",
"reason": "NotAuthenticated",
"message": "User is not authenticated to access resource.",
"code": 401
}{
"version": "1.0.0",
"status": "failure",
"reason": "NotAuthorized",
"message": "User has insufficient permission to access resource.",
"code": 403
}{
"version": "1.0.0",
"status": "failure",
"reason": "InvalidHeader",
"message": "Invalid header was provided with the request.",
"code": 406
}{
"version": "1.0.0",
"status": "ServerError",
"message": "An unexpected error occurred.",
"code": 500
}Authorizations
TokenAuthJWT
A plaintext token to secure your server, specified at startup in the argument --auth-token thisismysecret
Path Parameters
The REST channel used for custom integrations. They provide a URL where you can post messages and either receive response messages directly, or asynchronously via a webhook.
Available options:
rest, callback Body
application/json
The user message payload
⌘I
Post user message from a REST channel
curl --request POST \
--url 'http://localhost:5005/webhooks/{rest_channel}/webhook?token=' \
--header 'Content-Type: application/json' \
--data '
{
"sender": "default",
"message": "Hello!"
}
'import requests
url = "http://localhost:5005/webhooks/{rest_channel}/webhook?token="
payload = {
"sender": "default",
"message": "Hello!"
}
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({sender: 'default', message: 'Hello!'})
};
fetch('http://localhost:5005/webhooks/{rest_channel}/webhook?token=', 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 => "5005",
CURLOPT_URL => "http://localhost:5005/webhooks/{rest_channel}/webhook?token=",
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([
'sender' => 'default',
'message' => 'Hello!'
]),
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 := "http://localhost:5005/webhooks/{rest_channel}/webhook?token="
payload := strings.NewReader("{\n \"sender\": \"default\",\n \"message\": \"Hello!\"\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("http://localhost:5005/webhooks/{rest_channel}/webhook?token=")
.header("Content-Type", "application/json")
.body("{\n \"sender\": \"default\",\n \"message\": \"Hello!\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:5005/webhooks/{rest_channel}/webhook?token=")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"sender\": \"default\",\n \"message\": \"Hello!\"\n}"
response = http.request(request)
puts response.read_body[
{
"recipient_id": "default",
"text": "Hello!"
}
]{
"version": "1.0.0",
"status": "failure",
"reason": "NotAuthenticated",
"message": "User is not authenticated to access resource.",
"code": 401
}{
"version": "1.0.0",
"status": "failure",
"reason": "NotAuthorized",
"message": "User has insufficient permission to access resource.",
"code": 403
}{
"version": "1.0.0",
"status": "failure",
"reason": "InvalidHeader",
"message": "Invalid header was provided with the request.",
"code": 406
}{
"version": "1.0.0",
"status": "ServerError",
"message": "An unexpected error occurred.",
"code": 500
}