Verstuur een bericht
curl --request POST \
--url https://api.v1.sleak.chat/api/message \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"conversation_id": "8337afe2-2158-4332-a8aa-2946a357606p",
"message": "Hallo, ik heb een vraag over jullie producten"
}
'import requests
url = "https://api.v1.sleak.chat/api/message"
payload = {
"conversation_id": "8337afe2-2158-4332-a8aa-2946a357606p",
"message": "Hallo, ik heb een vraag over jullie producten"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
conversation_id: '8337afe2-2158-4332-a8aa-2946a357606p',
message: 'Hallo, ik heb een vraag over jullie producten'
})
};
fetch('https://api.v1.sleak.chat/api/message', 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://api.v1.sleak.chat/api/message",
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([
'conversation_id' => '8337afe2-2158-4332-a8aa-2946a357606p',
'message' => 'Hallo, ik heb een vraag over jullie producten'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.v1.sleak.chat/api/message"
payload := strings.NewReader("{\n \"conversation_id\": \"8337afe2-2158-4332-a8aa-2946a357606p\",\n \"message\": \"Hallo, ik heb een vraag over jullie producten\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.v1.sleak.chat/api/message")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"conversation_id\": \"8337afe2-2158-4332-a8aa-2946a357606p\",\n \"message\": \"Hallo, ik heb een vraag over jullie producten\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.v1.sleak.chat/api/message")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"conversation_id\": \"8337afe2-2158-4332-a8aa-2946a357606p\",\n \"message\": \"Hallo, ik heb een vraag over jullie producten\"\n}"
response = http.request(request)
puts response.read_body{
"messages": [
{
"id": "msg_123456",
"type": "ai_response",
"message_type": "default_bot",
"body": "Hallo! Ik help je graag met vragen over onze producten.",
"message_type_data": {},
"outputlogs": {}
}
],
"chat_id": "<string>",
"process_time": 123,
"source_documents": [
{}
],
"execution_metrics": {}
}{
"detail": "API key not found or invalid",
"error": "invalid_api_key"
}{
"detail": "API key not found or invalid",
"error": "invalid_api_key"
}{
"detail": "API key not found or invalid",
"error": "invalid_api_key"
}{
"detail": "API key not found or invalid",
"error": "invalid_api_key"
}{
"detail": "API key not found or invalid",
"error": "invalid_api_key"
}{
"detail": "API key not found or invalid",
"error": "invalid_api_key"
}API Reference
Verstuur een bericht
Verstuurt een bericht naar een bestaande conversatie en ontvangt een AI-gegenereerd antwoord
POST
/
api
/
message
Verstuur een bericht
curl --request POST \
--url https://api.v1.sleak.chat/api/message \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"conversation_id": "8337afe2-2158-4332-a8aa-2946a357606p",
"message": "Hallo, ik heb een vraag over jullie producten"
}
'import requests
url = "https://api.v1.sleak.chat/api/message"
payload = {
"conversation_id": "8337afe2-2158-4332-a8aa-2946a357606p",
"message": "Hallo, ik heb een vraag over jullie producten"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
conversation_id: '8337afe2-2158-4332-a8aa-2946a357606p',
message: 'Hallo, ik heb een vraag over jullie producten'
})
};
fetch('https://api.v1.sleak.chat/api/message', 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://api.v1.sleak.chat/api/message",
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([
'conversation_id' => '8337afe2-2158-4332-a8aa-2946a357606p',
'message' => 'Hallo, ik heb een vraag over jullie producten'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.v1.sleak.chat/api/message"
payload := strings.NewReader("{\n \"conversation_id\": \"8337afe2-2158-4332-a8aa-2946a357606p\",\n \"message\": \"Hallo, ik heb een vraag over jullie producten\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.v1.sleak.chat/api/message")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"conversation_id\": \"8337afe2-2158-4332-a8aa-2946a357606p\",\n \"message\": \"Hallo, ik heb een vraag over jullie producten\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.v1.sleak.chat/api/message")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"conversation_id\": \"8337afe2-2158-4332-a8aa-2946a357606p\",\n \"message\": \"Hallo, ik heb een vraag over jullie producten\"\n}"
response = http.request(request)
puts response.read_body{
"messages": [
{
"id": "msg_123456",
"type": "ai_response",
"message_type": "default_bot",
"body": "Hallo! Ik help je graag met vragen over onze producten.",
"message_type_data": {},
"outputlogs": {}
}
],
"chat_id": "<string>",
"process_time": 123,
"source_documents": [
{}
],
"execution_metrics": {}
}{
"detail": "API key not found or invalid",
"error": "invalid_api_key"
}{
"detail": "API key not found or invalid",
"error": "invalid_api_key"
}{
"detail": "API key not found or invalid",
"error": "invalid_api_key"
}{
"detail": "API key not found or invalid",
"error": "invalid_api_key"
}{
"detail": "API key not found or invalid",
"error": "invalid_api_key"
}{
"detail": "API key not found or invalid",
"error": "invalid_api_key"
}Dit endpoint verstuurt een bericht naar een bestaande conversatie en retourneert het antwoord van de AI-chatbot.
Voorbeeld
curl -X POST https://api.v1.sleak.chat/api/message \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"conversation_id": "conv_abc123def456",
"message": "Wat zijn jullie openingstijden?"
}'
Response
{
"messages": [
{
"role": "user",
"content": "Wat zijn jullie openingstijden?",
"timestamp": "2024-02-15T12:35:10Z"
},
{
"role": "assistant",
"content": "Onze klantenservice is bereikbaar van maandag t/m vrijdag van 9:00 tot 17:00 uur.",
"timestamp": "2024-02-15T12:35:12Z",
"metadata": {
"sources": ["kennisbank_artikel_123"],
"tools_used": ["kennisbank_zoeken"]
}
}
],
"conversation_id": "conv_abc123def456"
}
Berichtlengte limietBerichten kunnen tussen 1 en 4000 karakters lang zijn. Langere berichten worden afgewezen met een 400 error.
Metadata in responsesHet antwoord bevat optionele metadata zoals gebruikte databronnen en tools. Dit helpt bij debugging en het begrijpen van hoe de chatbot tot het antwoord kwam.
Authorizations
Gebruik je API sleutel als Bearer token.
Voorbeeld: Authorization: Bearer 28339789ad921d554cddc678e3e91bd3ff6676cb209741aa30b818135ef33060
Body
application/json
Response
Bericht succesvol verwerkt
Array van berichten van de chatbot
Show child attributes
Show child attributes
ID van de chat sessie
Verwerkingstijd in seconden
Bronndocumenten gebruikt voor het antwoord
Uitvoeringsstatistieken
⌘I

