Developer Documentation
Comprehensive guide for integrating with Oktagon's AI Voice Engine Agent platform
Chat API
Send messages to your AI agents and receive intelligent responses with optional action execution.
Endpoint
POST https://data.oktagonapp.com/api/chat-enhanced
Request Headers
Content-Type: application/json
Request Payload
{
"messages": [
{
"role": "user",
"content": "I need a navy blue suit for a business meeting. What do you recommend?"
}
],
"model": "gpt-4o",
"temperature": 0.2,
"systemPrompt": "You are a helpful clothing store assistant. Help customers find the right clothing items.",
"max_tokens": 1000,
"top_p": 1,
"user_id": "[userId]",
"agent_id": "[agentId]",
"sessionId": "store-session-123",
"enableActions": true
}
Tip: When you include agent_id
you can omit systemPrompt
; the API will automatically load the agent's saved instructions or system prompt from Oktagon.
{
"messages": [
{
"role": "user",
"content": "Review John Doe's vitals and suggest next steps."
}
],
"user_id": "patient-123",
"agent_id": "health-agent-1"
}
Response
{
"choices": [
{
"delta": {
"content": "I don't have that information in my knowledge base. However, I can suggest using available tools or resources to find recommendations for a navy blue suit suitable for a business meeting."
}
}
],
"ragEnabled": true,
"actionsEnabled": true
}
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
messages | Array | Yes | Array of message objects with role and content |
model | String | No | AI model to use (default: gpt-4o) |
temperature | Number | No | Creativity level (0.0 to 1.0, default: 0) |
systemPrompt | String | No | System instructions for the AI. Optional when agent_id is provided (the API will use the agent's stored prompt/instructions). |
max_tokens | Number | No | Maximum tokens to generate in the response |
top_p | Number | No | Nucleus sampling parameter (0.0 to 1.0) |
user_id | String | No | External user identifier used for analytics and action resolution |
agent_id | String | No | Agent identifier; required for action execution |
sessionId | String | No | Conversation/session identifier used for grouping interactions |
enableActions | Boolean | No | Whether to execute custom actions |
Actions API
Manage custom actions that your agents can perform, such as API calls, database queries, or external service integrations.
Get Actions
GET https://data.oktagonapp.com/api/actions?agentId=[agentId]&userId=[userId]
Get Specific Action
GET https://data.oktagonapp.com/api/actions?agentId=[agentId]&userId=[userId]&actionId=clothing-recommendations
Create Action
POST https://data.oktagonapp.com/api/actions
Request Payload
{
"actionId": "clothing-recommendations",
"name": "Get Clothing Recommendations",
"description": "Get personalized clothing recommendations based on customer preferences and style",
"whenToUse": "Use this action when customers ask for clothing recommendations, style advice, outfit suggestions, or want to find specific clothing items.",
"inputs": [
{
"name": "category",
"type": "string",
"description": "Clothing category (suits, shirts, pants, jackets, shoes, accessories)",
"required": true
},
{
"name": "color",
"type": "string",
"description": "Preferred color",
"required": false
},
{
"name": "size",
"type": "string",
"description": "Size preference",
"required": false
},
{
"name": "occasion",
"type": "string",
"description": "Occasion (business, casual, formal, weekend)",
"required": false
},
{
"name": "maxPrice",
"type": "number",
"description": "Maximum price budget",
"required": false
}
],
"apiRequest": {
"method": "POST",
"url": "https://data.oktagonapp.com/api/inventory",
"headers": {
"Content-Type": "application/json"
},
"body": {
"category": "{{category}}",
"color": "{{color}}",
"size": "{{size}}",
"occasion": "{{occasion}}",
"maxPrice": "{{maxPrice}}"
}
},
"dataAccess": "limited",
"enabled": true,
"agentId": "[agentId]",
"userId": "[userId]"
}
Execute Action
{
"actionId": "clothing-recommendations",
"agentId": "[agentId]",
"userId": "[userId]",
"sessionId": "store-session-123",
"inputs": {
"category": "suits",
"color": "navy"
}
}
Response
{
"actions": [
{
"id": "weather-api",
"name": "Get Weather",
"description": "Get current weather information for any city",
"whenToUse": "Use this action when users ask about weather conditions, temperature, or weather forecasts for specific cities or locations.",
"inputs": [
{
"name": "city",
"type": "string",
"description": "The city name to get weather for",
"required": true
}
],
"apiRequest": {
"method": "GET",
"url": "https://wttr.in/{{city}}?format=j1",
"headers": {
"User-Agent": "Oktagon-AI-Agent"
}
},
"dataAccess": "full",
"enabled": true,
"createdAt": "[timestamp]",
"updatedAt": "[timestamp]"
}
]
}
Update Action
PUT https://data.oktagonapp.com/api/actions
Delete Action
DELETE https://data.oktagonapp.com/api/actions
Error Response
{
"error": "Internal server error",
"message": "Action test-weather-api not found"
}
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
name | String | Yes | Display name for the action |
description | String | Yes | Detailed description of what the action does |
whenToUse | String | Yes | Instructions for when the AI should use this action |
inputs | Array / Object | No | Input definitions when creating an action, or runtime values when executing |
actionId | String | Yes | Unique identifier for the action (also required when executing) |
apiRequest | Object | Yes | HTTP request configuration |
dataAccess | String | No | Data access level: "full", "limited", or "none" |
enabled | Boolean | No | Whether the action is enabled |
agentId | String | Yes (execute) | Agent whose action set should be used when executing |
userId | String | Yes (execute & list) | User requesting the action; used for filtering and auditing |
sessionId | String | No | Optional session identifier when executing an action |
Website Crawling API
Crawl websites to extract content, links, and product information for your agents to use.
Endpoint
POST https://data.oktagonapp.com/api/crawl
Request Payload
{
"url": "https://example.com",
"includePaths": "/products/*,/blog/*",
"excludePaths": "/admin/*,/private/*",
"slowScraping": false,
"maxDepth": 2,
"maxPages": 10
}
Response
{
"success": true,
"data": {
"pages": [
{
"url": "https://example.com",
"title": "Example Domain",
"content": "Example Domain This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission. More information...",
"products": []
}
],
"products": [],
"links": [],
"totalPages": 1,
"totalProducts": 0,
"totalLinks": 0,
"crawledAt": "[timestamp]"
}
}
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
url | String | Yes | Website URL to crawl |
includePaths | String | No | Comma-separated path patterns to include |
excludePaths | String | No | Comma-separated path patterns to exclude |
slowScraping | Boolean | No | Add delays to avoid rate limiting |
maxDepth | Number | No | Maximum crawl depth (default: 2) |
maxPages | Number | No | Maximum pages to crawl (default: 10) |
Agent Info API
Retrieve the public configuration for an existing agent.
Endpoint
GET https://data.oktagonapp.com/api/agents/[agentId]
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
agentId | String | Yes | Identifier of the agent document to retrieve |
Response
{
"agent": {
"id": "[agentId]",
"name": "Clothing Store Assistant",
"description": "AI assistant for clothing store customer service",
"status": "active",
"chatWidth": "360px",
"theme": "light",
"initialMessage": "Hi there!",
"messagePlaceholder": "Type your message...",
"suggestedMessages": [
"Do you have navy suits?",
"What sizes are available?"
],
"createdAt": "[timestamp]",
"updatedAt": "[timestamp]"
}
}
Response Fields
Field | Type | Description |
---|---|---|
agent.id | String | Agent identifier |
agent.name | String | Display name from the dashboard |
agent.description | String | Optional description shown in the dashboard |
agent.status | String | Current agent status (for example active or draft ) |
agent.chatWidth | String | Width used by the hosted chat UI |
agent.theme | String | Theme identifier configured for the agent |
agent.initialMessage | String | Message shown to visitors when the chat opens |
agent.messagePlaceholder | String | Placeholder text for the chat input |
agent.suggestedMessages | Array<String> | Quick replies configured for the agent |
agent.createdAt | Timestamp | Creation time stored in Firestore |
agent.updatedAt | Timestamp | Last update time |
Authentication
Most API endpoints do not require authentication. However, for enhanced security and rate limiting, you can include an API key in the Authorization header:
Authorization: Bearer <Your-API-Key>
Getting Your API Key
- Log in to your Oktagon dashboard
- Navigate to Settings → API Keys
- Generate a new API key
- Copy and securely store your key
JavaScript SDK
Integrate Oktagon into your web applications with our JavaScript SDK.
Installation
npm install @oktagon/sdk
Basic Usage
import { OktagonClient } from '@oktagon/sdk';
const client = new OktagonClient({
apiKey: 'your-api-key',
baseUrl: 'https://data.oktagonapp.com'
});
// Send a message
const response = await client.chat.sendMessage({
message: 'Hello!',
agentId: 'your-agent-id',
userId: 'user-123'
});
console.log(response.message);
Embed Widget
<script src="https://data.oktagonapp.com/embed.js"></script>
<script>
Oktagon.init({
agentId: 'your-agent-id',
userId: 'user-123',
theme: 'light'
});
</script>