Developer Documentation

Dashboard

Introduction

Welcome to our API documentation. This guide will help you integrate our advanced AI-powered chatbot services into your applications. Our API allows you to create, manage, and interact with chatbots, as well as analyze their performance and leverage cutting-edge AI technologies.

Key Features

  • Create and manage multiple chatbots with advanced customization options
  • Utilize state-of-the-art natural language processing models
  • Seamless integration with popular messaging platforms and voice assistants
  • Real-time analytics and performance insights
  • Fine-tune AI models for improved accuracy and domain-specific knowledge
  • Multi-language support with automatic translation
  • Advanced sentiment analysis and intent recognition

Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Obtaining an API Key

To obtain an API key:

  1. Log in to your account dashboard
  2. Navigate to the "API Keys" section
  3. Click on "Generate New API Key"
  4. Copy and securely store your new API key

API Key Rotation

We recommend rotating your API keys periodically for enhanced security. To rotate your key:

  1. Generate a new API key
  2. Update your applications to use the new key
  3. Verify that everything works correctly with the new key
  4. Revoke the old API key

Endpoints

Chatbots

  • GET /api/v1/chatbots - List all chatbots
  • POST /api/v1/chatbots - Create a new chatbot
  • GET /api/v1/chatbots/{id} - Get chatbot details
  • PUT /api/v1/chatbots/{id} - Update a chatbot
  • DELETE /api/v1/chatbots/{id} - Delete a chatbot
  • POST /api/v1/chatbots/{id}/train - Fine-tune chatbot model

Conversations

  • POST /api/v1/chatbots/{id}/conversations - Start a new conversation
  • POST /api/v1/conversations/{id}/messages - Send a message in a conversation
  • GET /api/v1/conversations/{id} - Get conversation history
  • POST /api/v1/conversations/{id}/analyze - Perform sentiment analysis

Analytics

  • GET /api/v1/chatbots/{id}/analytics - Get chatbot analytics
  • GET /api/v1/analytics/usage - Get API usage statistics
  • GET /api/v1/analytics/performance - Get real-time performance metrics

Error Handling

Our API uses conventional HTTP response codes to indicate success or failure of requests. In general:

  • 2xx: Success
  • 4xx: Client errors
  • 5xx: Server errors

Common Error Codes

Code Description
400 Bad Request - Invalid parameters
401 Unauthorized - Invalid API key
404 Not Found - Resource doesn't exist
429 Too Many Requests - Rate limit exceeded

Rate Limiting

API requests are limited to ensure fair usage and maintain service stability. The current limits are:

  • 1000 requests per hour per API key
  • 10,000 requests per day per API key

If you exceed these limits, you'll receive a 429 Too Many Requests response. The response will include the following headers:

  • X-RateLimit-Limit: The rate limit period (per hour or per day)
  • X-RateLimit-Remaining: The number of requests left for the time window
  • X-RateLimit-Reset: The time at which the current rate limit window resets in UTC epoch seconds

Examples

Python


import requests

api_key = "your_api_key_here"
headers = {"Authorization": f"Bearer {api_key}"}
base_url = "https://api.example.com/v1"

# Create a new chatbot
new_chatbot = {
    "name": "Customer Support Bot",
    "description": "A chatbot for handling customer inquiries",
    "language": "en"
}
response = requests.post(f"{base_url}/chatbots", json=new_chatbot, headers=headers)
chatbot = response.json()
print(f"Created chatbot: {chatbot['id']}")

# Start a conversation
conversation = requests.post(f"{base_url}/chatbots/{chatbot['id']}/conversations", headers=headers).json()
conversation_id = conversation['id']

# Send a message
message = {
    "content": "Hello, I have a question about my order.",
    "role": "user"
}
response = requests.post(f"{base_url}/conversations/{conversation_id}/messages", json=message, headers=headers)
bot_response = response.json()
print(f"Bot response: {bot_response['content']}")
                

JavaScript


const axios = require('axios');

const apiKey = 'your_api_key_here';
const baseURL = 'https://api.example.com/v1';

const api = axios.create({
  baseURL,
  headers: { Authorization: `Bearer ${apiKey}` }
});

async function createChatbotAndConverse() {
  try {
    // Create a new chatbot
    const { data: chatbot } = await api.post('/chatbots', {
      name: 'Customer Support Bot',
      description: 'A chatbot for handling customer inquiries',
      language: 'en'
    });
    console.log(`Created chatbot: ${chatbot.id}`);

    // Start a conversation
    const { data: conversation } = await api.post(`/chatbots/${chatbot.id}/conversations`);

    // Send a message
    const { data: botResponse } = await api.post(`/conversations/${conversation.id}/messages`, {
      content: 'Hello, I have a question about my order.',
      role: 'user'
    });
    console.log(`Bot response: ${botResponse.content}`);
  } catch (error) {
    console.error('Error:', error.response ? error.response.data : error.message);
  }
}

createChatbotAndConverse();
                

SDKs

We provide official SDKs for the following languages:

  • Python: pip install example-chatbot-sdk
  • JavaScript: npm install example-chatbot-sdk
  • Ruby: gem install example-chatbot-sdk
  • PHP: composer require example/chatbot-sdk

For detailed documentation on using our SDKs, please visit the respective GitHub repositories:

Frequently Asked Questions

How do I reset my API key?
You can reset your API key from your account settings page. Navigate to the "API Keys" section and click on "Regenerate API Key". Note that this will invalidate your old API key immediately.
Is there a sandbox environment for testing?
Yes, we provide a sandbox environment for testing. Use the base URL https://api-sandbox.example.com for all your test requests. The sandbox environment has the same functionality as the production environment but does not affect your live data or billing.
How do I report bugs or request features?
Please submit issues and feature requests through our GitHub repository or contact our support team at support@example.com. For urgent matters, you can reach out to us via the live chat on our website.
What's the difference between the various subscription plans?
Our subscription plans differ in terms of API call limits, available features, and support levels. You can find a detailed comparison on our pricing page. If you have specific needs, please contact our sales team for a custom plan.
Can I use your API in my mobile app?
Absolutely! Our API is designed to work with any platform, including mobile apps. We recommend using one of our official SDKs for easier integration. Make sure to follow mobile best practices, such as not storing the API key directly in your app's code.

Changelog

  • v3.0.0 (2023-09-01)

    • Introduced advanced NLP models with improved understanding and response generation
    • Added support for voice assistant integration
    • New endpoint: POST /api/v1/chatbots/{id}/train for fine-tuning models
    • Enhanced multi-language support with automatic translation
  • v2.1.0 (2023-06-15)

    • Added support for multi-language chatbots
    • Improved response time for high-traffic chatbots
    • New endpoint: GET /api/v1/chatbots/{id}/performance
  • v2.0.0 (2023-05-01)

    • Major API overhaul with breaking changes (see migration guide)
    • Introduced conversation management endpoints
    • Added support for custom AI model fine-tuning
  • v1.5.2 (2023-03-10)

    • Fixed a bug in the rate limiting algorithm
    • Improved error messages for better debugging

Best Practices

  • Use HTTPS for all API requests to ensure data security
  • Implement proper error handling in your applications
  • Cache API responses when appropriate to reduce unnecessary requests
  • Use our official SDKs for easier integration and better performance
  • Monitor your API usage and set up alerts for unusual activity
  • Keep your API keys secure and rotate them regularly
  • Use webhook endpoints for real-time updates instead of polling