Skip to main content

Bots

The Bots API allows you to create and manage AI-powered chatbots that handle conversations automatically.

Overview​

Bots in Linktor are AI agents that can respond to customer messages, execute actions, and escalate to human agents when needed. Bots can be powered by various AI providers (OpenAI, Anthropic, custom LLMs) and can be configured with custom instructions, knowledge bases, and conversation flows.

Endpoints​

MethodEndpointDescription
GET/botsList all bots
GET/bots/:idGet a specific bot
POST/botsCreate a new bot
PATCH/bots/:idUpdate a bot
DELETE/bots/:idDelete a bot
POST/bots/:id/activateActivate a bot
POST/bots/:id/deactivateDeactivate a bot
POST/bots/:id/testTest bot with a message
GET/bots/:id/statsGet bot statistics
POST/bots/:id/trainTrigger knowledge base training

List Bots​

Retrieve all bots for your organization.

GET /bots

Query Parameters​

ParameterTypeDefaultDescription
pageinteger1Page number
perPageinteger20Items per page (max: 100)
statusstring-Filter by status: active, inactive, training
providerstring-Filter by AI provider
searchstring-Search by bot name

Example Request​

curl "https://api.linktor.io/v1/bots?status=active" \
-H "Authorization: Bearer YOUR_API_KEY"

Response​

{
"data": [
{
"id": "bot_abc123",
"type": "bot",
"attributes": {
"name": "Support Bot",
"description": "Handles customer support inquiries",
"status": "active",
"provider": "openai",
"model": "gpt-4",
"stats": {
"conversationsHandled24h": 150,
"messagesProcessed24h": 1200,
"avgResponseTime": 1.5,
"handoffRate": 0.12
},
"channels": [
{
"id": "ch_xyz789",
"name": "WhatsApp Business"
}
],
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-15T10:00:00Z"
}
}
],
"meta": {
"pagination": {
"page": 1,
"perPage": 20,
"totalPages": 1,
"totalCount": 1
}
}
}

Get Bot​

Retrieve a specific bot by ID.

GET /bots/:id

Path Parameters​

ParameterTypeDescription
idstringBot ID

Example Request​

curl https://api.linktor.io/v1/bots/bot_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"

Response​

{
"data": {
"id": "bot_abc123",
"type": "bot",
"attributes": {
"name": "Support Bot",
"description": "Handles customer support inquiries",
"status": "active",
"provider": "openai",
"model": "gpt-4",
"config": {
"systemPrompt": "You are a helpful customer support agent for Acme Corp. Be friendly, professional, and concise.",
"temperature": 0.7,
"maxTokens": 500,
"topP": 1.0,
"frequencyPenalty": 0,
"presencePenalty": 0
},
"behaviors": {
"greeting": {
"enabled": true,
"message": "Hello! I'm the Acme support assistant. How can I help you today?"
},
"fallback": {
"enabled": true,
"message": "I'm not sure I understand. Could you rephrase that?",
"maxRetries": 2
},
"handoff": {
"enabled": true,
"triggers": ["speak to human", "agent", "representative"],
"message": "I'll connect you with a human agent. Please wait a moment."
},
"offlineMessage": {
"enabled": true,
"message": "Our support team is currently offline. Please leave a message and we'll get back to you."
}
},
"knowledgeBase": {
"id": "kb_xyz789",
"name": "Product Knowledge Base",
"documentCount": 150,
"lastTrainedAt": "2024-01-14T00:00:00Z"
},
"flow": {
"id": "flow_abc",
"name": "Support Flow"
},
"capabilities": {
"textResponses": true,
"imageGeneration": false,
"codeExecution": false,
"webSearch": false,
"functionCalling": true
},
"functions": [
{
"name": "get_order_status",
"description": "Get the status of a customer order",
"parameters": {
"type": "object",
"properties": {
"orderId": {
"type": "string",
"description": "The order ID"
}
},
"required": ["orderId"]
}
},
{
"name": "create_ticket",
"description": "Create a support ticket",
"parameters": {
"type": "object",
"properties": {
"subject": {"type": "string"},
"priority": {"type": "string", "enum": ["low", "normal", "high"]}
},
"required": ["subject"]
}
}
],
"channels": [
{
"id": "ch_xyz789",
"name": "WhatsApp Business",
"type": "whatsapp"
}
],
"stats": {
"conversationsHandled24h": 150,
"conversationsHandledTotal": 15000,
"messagesProcessed24h": 1200,
"messagesProcessedTotal": 120000,
"avgResponseTime": 1.5,
"avgConversationLength": 8,
"handoffRate": 0.12,
"satisfactionScore": 4.5
},
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-15T10:00:00Z"
}
}
}

Error Codes​

HTTP StatusError CodeDescription
404BOT_NOT_FOUNDBot does not exist

Create Bot​

Create a new bot.

POST /bots

Request Body​

FieldTypeRequiredDescription
namestringYesBot display name
descriptionstringNoBot description
providerstringYesAI provider: openai, anthropic, custom
modelstringYesModel identifier
configobjectNoModel configuration
behaviorsobjectNoBot behavior settings
knowledgeBaseIdstringNoKnowledge base to use
flowIdstringNoConversation flow to use
functionsarrayNoCustom functions
channelIdsarrayNoChannels to assign bot to

Example Request​

curl -X POST https://api.linktor.io/v1/bots \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Sales Bot",
"description": "Handles product inquiries and sales",
"provider": "openai",
"model": "gpt-4",
"config": {
"systemPrompt": "You are a helpful sales assistant for Acme Corp. Help customers find the right products and answer questions about pricing and features. Be friendly and persuasive but not pushy.",
"temperature": 0.8,
"maxTokens": 600
},
"behaviors": {
"greeting": {
"enabled": true,
"message": "Hi there! Welcome to Acme. What are you looking for today?"
},
"handoff": {
"enabled": true,
"triggers": ["buy", "purchase", "pricing for enterprise"],
"message": "Great choice! Let me connect you with our sales team."
}
},
"knowledgeBaseId": "kb_products",
"channelIds": ["ch_webchat"]
}'

Response​

{
"data": {
"id": "bot_new456",
"type": "bot",
"attributes": {
"name": "Sales Bot",
"description": "Handles product inquiries and sales",
"status": "inactive",
"provider": "openai",
"model": "gpt-4",
"config": {
"systemPrompt": "You are a helpful sales assistant...",
"temperature": 0.8,
"maxTokens": 600
},
"behaviors": {
"greeting": {
"enabled": true,
"message": "Hi there! Welcome to Acme. What are you looking for today?"
},
"handoff": {
"enabled": true,
"triggers": ["buy", "purchase", "pricing for enterprise"],
"message": "Great choice! Let me connect you with our sales team."
}
},
"knowledgeBase": {
"id": "kb_products",
"name": "Product Catalog"
},
"channels": [
{
"id": "ch_webchat",
"name": "Website Chat"
}
],
"createdAt": "2024-01-15T11:00:00Z"
}
}
}

Error Codes​

HTTP StatusError CodeDescription
400VALIDATION_ERRORInvalid configuration
400INVALID_PROVIDERUnsupported AI provider
400INVALID_MODELModel not available for provider
404KNOWLEDGE_BASE_NOT_FOUNDKnowledge base not found
404FLOW_NOT_FOUNDFlow not found

Update Bot​

Update an existing bot.

PATCH /bots/:id

Path Parameters​

ParameterTypeDescription
idstringBot ID

Request Body​

FieldTypeDescription
namestringBot display name
descriptionstringBot description
modelstringModel identifier
configobjectModel configuration
behaviorsobjectBehavior settings
knowledgeBaseIdstringKnowledge base ID
flowIdstringFlow ID
functionsarrayCustom functions
channelIdsarrayChannel assignments

Example Request​

curl -X PATCH https://api.linktor.io/v1/bots/bot_abc123 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"config": {
"systemPrompt": "Updated system prompt with new instructions...",
"temperature": 0.5
},
"behaviors": {
"handoff": {
"enabled": true,
"triggers": ["agent", "human", "help me please"],
"message": "Connecting you to a human agent now."
}
}
}'

Response​

{
"data": {
"id": "bot_abc123",
"type": "bot",
"attributes": {
"name": "Support Bot",
"config": {
"systemPrompt": "Updated system prompt with new instructions...",
"temperature": 0.5,
"maxTokens": 500
},
"behaviors": {
"handoff": {
"enabled": true,
"triggers": ["agent", "human", "help me please"],
"message": "Connecting you to a human agent now."
}
},
"updatedAt": "2024-01-15T12:00:00Z"
}
}
}

Delete Bot​

Delete a bot. The bot must be deactivated first.

DELETE /bots/:id

Path Parameters​

ParameterTypeDescription
idstringBot ID

Example Request​

curl -X DELETE https://api.linktor.io/v1/bots/bot_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"

Response​

HTTP/1.1 204 No Content

Error Codes​

HTTP StatusError CodeDescription
400BOT_IS_ACTIVEBot must be deactivated first
404BOT_NOT_FOUNDBot does not exist

Activate Bot​

Enable a bot to start handling conversations.

POST /bots/:id/activate

Path Parameters​

ParameterTypeDescription
idstringBot ID

Example Request​

curl -X POST https://api.linktor.io/v1/bots/bot_abc123/activate \
-H "Authorization: Bearer YOUR_API_KEY"

Response​

{
"data": {
"id": "bot_abc123",
"type": "bot",
"attributes": {
"status": "active",
"activatedAt": "2024-01-15T12:00:00Z"
}
}
}

Deactivate Bot​

Disable a bot. Active conversations will be transferred to fallback handling.

POST /bots/:id/deactivate

Path Parameters​

ParameterTypeDescription
idstringBot ID

Request Body​

FieldTypeRequiredDescription
transferTostringNoUser/bot ID to transfer conversations
reasonstringNoDeactivation reason

Example Request​

curl -X POST https://api.linktor.io/v1/bots/bot_abc123/deactivate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"transferTo": "bot_fallback",
"reason": "Updating knowledge base"
}'

Response​

{
"data": {
"id": "bot_abc123",
"type": "bot",
"attributes": {
"status": "inactive",
"deactivatedAt": "2024-01-15T12:00:00Z",
"conversationsTransferred": 5
}
}
}

Test Bot​

Send a test message to the bot and get a response.

POST /bots/:id/test

Path Parameters​

ParameterTypeDescription
idstringBot ID

Request Body​

FieldTypeRequiredDescription
messagestringYesTest message
contextobjectNoConversation context
context.historyarrayNoPrevious messages
context.metadataobjectNoContact/conversation metadata

Example Request​

curl -X POST https://api.linktor.io/v1/bots/bot_abc123/test \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "What are your business hours?",
"context": {
"history": [
{"role": "user", "content": "Hi there"},
{"role": "assistant", "content": "Hello! How can I help you today?"}
],
"metadata": {
"customerTier": "premium"
}
}
}'

Response​

{
"data": {
"response": {
"content": "Our business hours are Monday to Friday, 9 AM to 6 PM EST. On weekends, we have limited support from 10 AM to 2 PM. Is there anything specific you need help with during these hours?",
"confidence": 0.95,
"intent": "business_hours_inquiry",
"sources": [
{
"type": "knowledge_base",
"documentId": "doc_hours",
"excerpt": "Business hours: Mon-Fri 9AM-6PM EST..."
}
]
},
"usage": {
"promptTokens": 150,
"completionTokens": 45,
"totalTokens": 195
},
"latency": 1.2
}
}

Get Bot Statistics​

Retrieve detailed statistics for a bot.

GET /bots/:id/stats

Path Parameters​

ParameterTypeDescription
idstringBot ID

Query Parameters​

ParameterTypeDefaultDescription
periodstring24hTime period: 1h, 24h, 7d, 30d

Example Request​

curl "https://api.linktor.io/v1/bots/bot_abc123/stats?period=7d" \
-H "Authorization: Bearer YOUR_API_KEY"

Response​

{
"data": {
"botId": "bot_abc123",
"period": "7d",
"conversations": {
"total": 1050,
"resolved": 920,
"handedOff": 130,
"avgLength": 8.5,
"avgDuration": 420
},
"messages": {
"received": 8500,
"sent": 7800,
"avgResponseTime": 1.3
},
"performance": {
"resolutionRate": 0.876,
"handoffRate": 0.124,
"satisfactionScore": 4.6,
"feedbackCount": 250
},
"usage": {
"totalTokens": 1500000,
"promptTokens": 1000000,
"completionTokens": 500000,
"estimatedCost": 45.00
},
"topIntents": [
{"intent": "order_status", "count": 320},
{"intent": "product_inquiry", "count": 280},
{"intent": "pricing", "count": 150}
],
"topHandoffReasons": [
{"reason": "complex_issue", "count": 50},
{"reason": "customer_request", "count": 45},
{"reason": "out_of_scope", "count": 35}
]
}
}

Train Knowledge Base​

Trigger a knowledge base training/sync for the bot.

POST /bots/:id/train

Path Parameters​

ParameterTypeDescription
idstringBot ID

Request Body​

FieldTypeRequiredDescription
fullRetrainbooleanNoForce full retrain (default: incremental)

Example Request​

curl -X POST https://api.linktor.io/v1/bots/bot_abc123/train \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fullRetrain": false
}'

Response​

{
"data": {
"trainingId": "train_xyz789",
"botId": "bot_abc123",
"status": "in_progress",
"type": "incremental",
"documentsToProcess": 15,
"startedAt": "2024-01-15T12:00:00Z",
"estimatedCompletion": "2024-01-15T12:05:00Z"
}
}

Supported Providers​

ProviderModels
openaigpt-4, gpt-4-turbo, gpt-3.5-turbo
anthropicclaude-3-opus, claude-3-sonnet, claude-3-haiku
customSelf-hosted or custom API endpoint

Bot Statuses​

StatusDescription
activeBot is handling conversations
inactiveBot is disabled
trainingKnowledge base is being updated
errorBot has configuration issues

Webhooks​

Bot events can be received via webhooks:

  • bot.created - New bot created
  • bot.updated - Bot configuration changed
  • bot.activated - Bot activated
  • bot.deactivated - Bot deactivated
  • bot.handoff - Bot handed off to human
  • bot.training.started - Training started
  • bot.training.completed - Training completed
  • bot.training.failed - Training failed

See Webhooks for configuration details.