Skip to main content
POST
/
api
/
conversation
Start een nieuwe conversatie
curl --request POST \
  --url https://api.v1.sleak.chat/api/conversation \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "chatbot_id": "307e6946-bc23-4fb7-8458-d8121465f2aq",
  "visitor_id": "c428c263-a1d3-4072-bf64-525cefbfb0b1"
}
'
import requests

url = "https://api.v1.sleak.chat/api/conversation"

payload = {
"chatbot_id": "307e6946-bc23-4fb7-8458-d8121465f2aq",
"visitor_id": "c428c263-a1d3-4072-bf64-525cefbfb0b1"
}
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({
chatbot_id: '307e6946-bc23-4fb7-8458-d8121465f2aq',
visitor_id: 'c428c263-a1d3-4072-bf64-525cefbfb0b1'
})
};

fetch('https://api.v1.sleak.chat/api/conversation', 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/conversation",
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([
'chatbot_id' => '307e6946-bc23-4fb7-8458-d8121465f2aq',
'visitor_id' => 'c428c263-a1d3-4072-bf64-525cefbfb0b1'
]),
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/conversation"

payload := strings.NewReader("{\n \"chatbot_id\": \"307e6946-bc23-4fb7-8458-d8121465f2aq\",\n \"visitor_id\": \"c428c263-a1d3-4072-bf64-525cefbfb0b1\"\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/conversation")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"chatbot_id\": \"307e6946-bc23-4fb7-8458-d8121465f2aq\",\n \"visitor_id\": \"c428c263-a1d3-4072-bf64-525cefbfb0b1\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.v1.sleak.chat/api/conversation")

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 \"chatbot_id\": \"307e6946-bc23-4fb7-8458-d8121465f2aq\",\n \"visitor_id\": \"c428c263-a1d3-4072-bf64-525cefbfb0b1\"\n}"

response = http.request(request)
puts response.read_body
{
  "conversation_id": "63907bf7-89f7-421a-9f13-b6f23411aabv"
}
{
"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 creëert een nieuwe conversatie met een specifieke chatbot. Je ontvangt een conversation_id terug die je kunt gebruiken om berichten te versturen.

Voorbeeld

curl -X POST https://api.v1.sleak.chat/api/conversation \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chatbot_id": "chatbot_123",
    "visitor_id": "visitor_456"
  }'

Response

{
  "conversation_id": "conv_abc123def456",
  "chatbot_id": "chatbot_123",
  "visitor_id": "visitor_456",
  "created_at": "2024-02-15T12:34:56Z"
}
Visitor ID is optioneelDe visitor_id is optioneel maar aanbevolen voor het identificeren van terugkerende bezoekers en het behouden van gesprekshistorie.

Authorizations

Authorization
string
header
required

Gebruik je API sleutel als Bearer token. Voorbeeld: Authorization: Bearer 28339789ad921d554cddc678e3e91bd3ff6676cb209741aa30b818135ef33060

Body

application/json
chatbot_id
string
required

Unieke identifier van de chatbot

Example:

"307e6946-bc23-4fb7-8458-d8121465f2aq"

visitor_id
string

Optionele identifier voor de bezoeker. Als deze niet wordt opgegeven, wordt automatisch een unieke ID gegenereerd.

Example:

"c428c263-a1d3-4072-bf64-525cefbfb0b1"

Response

Conversatie succesvol aangemaakt

conversation_id
string

Unieke identifier van de aangemaakte conversatie

Example:

"63907bf7-89f7-421a-9f13-b6f23411aabv"