Loading...

Integration Documentation

Technical guide for developers and system integrators

API Documentation

Complete technical guide for integrating AISA with your applications

Quick Start

Before You Begin
  • Create an account at wa.ai-serviceagent.com
  • Get your API key from the dashboard
  • Set up your WhatsApp Business account
  • Have your website URL ready for AI training

Base URL

https://api.ai-serviceagent.com/v1

Authentication

All API requests require an API key in the header:

curl -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ https://api.ai-serviceagent.com/v1/chatbot

API Endpoints

Chatbot Management

POST/chatbot/create

Create a new AI chatbot from website URL

Request Body:
{ "website_url": "https://your-website.com", "chatbot_name": "My Business Chatbot", "language": "en", "industry": "e-commerce" }
Response:
{ "status": "success", "chatbot_id": "cb_1234567890", "training_status": "in_progress", "estimated_completion": "2-3 minutes" }
GET/chatbot/{chatbot_id}

Get chatbot details and training status

Response:
{ "chatbot_id": "cb_1234567890", "name": "My Business Chatbot", "status": "active", "website_url": "https://your-website.com", "created_at": "2025-08-09T10:30:00Z", "last_trained": "2025-08-09T10:33:00Z" }
PUT/chatbot/{chatbot_id}/retrain

Retrain chatbot with updated website content

Request Body:
{ "force_retrain": true, "include_new_pages": true }

Message Handling

POST/message/send

Send message through AI chatbot

Request Body:
{ "chatbot_id": "cb_1234567890", "user_message": "What are your business hours?", "user_id": "user_12345", "phone_number": "+60123456789" }
Response:
{ "status": "success", "response": "We're open Monday to Friday, 9 AM to 6 PM MYT. How can I help you today?", "message_id": "msg_1234567890", "confidence_score": 0.95 }
GET/message/history

Get conversation history for a user

Query Parameters:
  • user_id - User identifier
  • limit - Number of messages (default: 50)
  • offset - Pagination offset
Response:
{ "messages": [ { "message_id": "msg_1234567890", "user_message": "What are your business hours?", "ai_response": "We're open Monday to Friday, 9 AM to 6 PM MYT.", "timestamp": "2025-08-09T14:30:00Z", "confidence_score": 0.95 } ], "total_count": 25, "has_more": true }

Analytics & Reporting

GET/analytics/conversations

Get conversation analytics and metrics

Query Parameters:
  • start_date - Start date (YYYY-MM-DD)
  • end_date - End date (YYYY-MM-DD)
  • chatbot_id - Specific chatbot (optional)
Response:
{ "total_conversations": 1250, "total_messages": 5670, "avg_response_time": "0.8s", "customer_satisfaction": 4.6, "top_queries": [ "business hours", "pricing information", "contact details" ], "daily_breakdown": [ { "date": "2025-08-09", "conversations": 45, "messages": 198 } ] }

Webhooks

Configure webhooks to receive real-time notifications about conversations and events.

Setting Up Webhooks

POST/webhooks/configure
Request Body:
{ "url": "https://your-server.com/webhook", "events": ["message.received", "conversation.started", "conversation.ended"], "secret": "your_webhook_secret" }

Webhook Events

message.received

Triggered when a user sends a message

conversation.started

Triggered when a new conversation begins

conversation.ended

Triggered when a conversation is marked as completed

lead.captured

Triggered when a potential lead is identified

Webhook Payload Example

{ "event": "message.received", "timestamp": "2025-08-09T14:30:00Z", "data": { "conversation_id": "conv_1234567890", "user_id": "user_12345", "phone_number": "+60123456789", "message": "What are your business hours?", "ai_response": "We're open Monday to Friday, 9 AM to 6 PM MYT.", "confidence_score": 0.95 } }

SDKs & Libraries

JavaScript SDK

For web applications and Node.js

npm install @aisa/javascript-sdk
import AISA from '@aisa/javascript-sdk'; const aisa = new AISA('your_api_key'); const response = await aisa.sendMessage({ chatbotId: 'cb_1234567890', message: 'Hello', userId: 'user_12345' });
Python SDK

For Python applications and AI/ML workflows

pip install aisa-python-sdk
from aisa import AISA aisa = AISA(api_key='your_api_key') response = aisa.send_message( chatbot_id='cb_1234567890', message='Hello', user_id='user_12345' )
PHP SDK

For PHP web applications

composer require aisa/php-sdk
use AISA\Client; $aisa = new Client('your_api_key'); $response = $aisa->sendMessage([ 'chatbot_id' => 'cb_1234567890', 'message' => 'Hello', 'user_id' => 'user_12345' ]);
Java SDK

For Java and Android applications

<dependency> <groupId>com.aisa</groupId> <artifactId>java-sdk</artifactId> <version>1.0.0</version> </dependency>
import com.aisa.AISA; AISA aisa = new AISA("your_api_key"); MessageResponse response = aisa.sendMessage( "cb_1234567890", "Hello", "user_12345" );

Error Handling

The API uses standard HTTP status codes and returns detailed error messages in JSON format.

Error Response Format

{ "error": { "code": "INVALID_API_KEY", "message": "The provided API key is invalid or expired", "details": "Please check your API key in the dashboard" } }

Common Error Codes

HTTP Status Error Code Description
400 INVALID_REQUEST Request body is malformed or missing required fields
401 INVALID_API_KEY API key is invalid, expired, or missing
403 INSUFFICIENT_PERMISSIONS API key doesn't have required permissions
404 RESOURCE_NOT_FOUND Requested chatbot or resource doesn't exist
429 RATE_LIMIT_EXCEEDED Too many requests, please slow down
500 INTERNAL_ERROR Something went wrong on our end

Rate Limits

Current Rate Limits
  • Free Plan: 100 requests per hour
  • Pro Plan: 1,000 requests per hour
  • Enterprise Plan: 10,000 requests per hour

Rate limit information is included in response headers:

X-RateLimit-Limit: 1000 X-RateLimit-Remaining: 999 X-RateLimit-Reset: 1691580000

Developer Support

Documentation

Comprehensive guides and examples

View Guides
GitHub

Code samples and community discussions

GitHub Repo
Developer Support

Technical support for developers

Email Support