Skip to main content
Integrations connect your bots to AI backends that generate responses. An integration is a webhook configuration that defines how to communicate with services like OpenAI, Anthropic, or your own custom API.
Integrations page

Overview

An integration consists of:
  • Webhook URL: The endpoint to send messages to
  • HTTP Headers: Authentication and custom headers
  • Timeout: Maximum wait time for responses
  • Weight: For A/B testing (optional)
  • Payload Format: The request structure sent to your backend
Create integration

Creating an Integration

1

Navigate to Integrations

From your bot page, click Integrations in the sidebar.
2

Click Create Integration

Click the Create Integration button to open the form.
3

Configure Basic Settings

Enter the integration details:
Basic integration info
  • Name: Friendly name (e.g., “OpenAI GPT-4”)
  • Webhook URL: Your AI backend endpoint
  • Timeout: Response timeout in seconds (default: 30)
4

Add Headers (Optional)

Add authentication or custom headers:
Custom headers
Example headers:
Authorization: Bearer sk-...
Content-Type: application/json
X-Custom-Header: value
5

Configure Advanced Settings

Set additional options:
Advanced settings
  • Weight: For A/B testing (default: 1)
  • Fallback: Mark as fallback integration
6

Preview Payload

Review the payload format that will be sent:
Payload preview
7

Save

Click Create to save the integration.
Integration created

Request Payload Format

When a user sends a message, your integration receives a POST request with this structure:
{
  "messages": [
    {
      "role": "user",
      "content": "Hello, how are you?"
    }
  ],
  "conversation_id": "conv_123",
  "user": {
    "id": "user_456",
    "platform": "telegram",
    "name": "John Doe"
  },
  "bot": {
    "id": "bot_789",
    "name": "Support Bot"
  },
  "metadata": {
    "channel": "telegram",
    "chat_id": "123456789"
  }
}

Messages Array

The messages array contains conversation history based on your configured context window:
"messages": [
  {
    "role": "user",
    "content": "What's the weather?"
  },
  {
    "role": "assistant",
    "content": "I'll check the weather for you."
  },
  {
    "role": "user",
    "content": "Thanks"
  }
]
This follows the OpenAI/Anthropic message format for easy integration.

Expected Response

Your backend should return JSON with this structure:
{
  "content": "The response message to send to the user"
}
Or with metadata:
{
  "content": "The response message",
  "metadata": {
    "model": "gpt-4",
    "tokens": 150,
    "custom_field": "value"
  }
}
The content field is required. Everything else is optional and stored for your reference.

Integration Types

OpenAI Compatible

For OpenAI API or compatible services:
URL: https://api.openai.com/v1/chat/completions
Headers:
  Authorization: Bearer YOUR_API_KEY
  Content-Type: application/json
You’ll need to transform the payload or use a proxy that accepts our format.

Anthropic (Claude)

For Anthropic’s API:
URL: https://api.anthropic.com/v1/messages
Headers:
  x-api-key: YOUR_API_KEY
  anthropic-version: 2023-06-01
Use a proxy to transform our payload to Anthropic’s format.

Custom Backend

For your own API:
URL: https://your-domain.com/api/chat
Headers:
  Authorization: Bearer YOUR_TOKEN
  X-Custom: value
Your backend receives our payload format and returns content as JSON.

Fallback Integrations

Mark an integration as “fallback” to use it when the primary integration fails:
Fallback integration
Fallback behavior:
  1. Bot tries primary integration (highest weight)
  2. If it times out or errors, tries fallback
  3. If fallback also fails, sends error message to user
This provides reliability for production bots.

Webhook Setup

Detailed webhook configuration guide

A/B Testing

Compare multiple AI backends

Custom Headers

Authentication and custom headers

Testing Your Integration

Use the built-in test feature:
1

Go to Integration

Open the integration you want to test.
2

Click Test

Click the Test button.
3

Send Test Message

Enter a test message and submit.
4

Review Response

Check the response from your backend. Look for errors or unexpected behavior.

Troubleshooting

Timeout Errors

If requests timeout:
  • Increase timeout value
  • Optimize your backend for faster responses
  • Check network connectivity

Authentication Errors

If you get 401/403 errors:
  • Verify API keys are correct
  • Check header format
  • Ensure headers include required authentication

Invalid Response Format

If the bot can’t parse responses:
  • Ensure response is valid JSON
  • Include required content field
  • Check for encoding issues

API Access

Manage integrations programmatically using the API.
curl -X POST https://api.chatbotplatform.io/v1/bots/bot_123/integrations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "OpenAI GPT-4",
    "webhook_url": "https://api.openai.com/v1/chat/completions",
    "headers": {
      "Authorization": "Bearer sk-...",
      "Content-Type": "application/json"
    },
    "timeout": 30,
    "weight": 1
  }'
curl https://api.chatbotplatform.io/v1/bots/bot_123/integrations \
  -H "Authorization: Bearer YOUR_API_KEY"
curl -X PATCH https://api.chatbotplatform.io/v1/integrations/int_123 \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "timeout": 60,
    "weight": 2
  }'

Complete API Reference

View the full API specification with all endpoints, parameters, and response schemas.

Next Steps

Webhook Setup Guide

Detailed setup instructions

A/B Testing

Configure multiple integrations