Back to arky.io

AI Agents

Create conversational AI agents with chat capabilities

AI Agents provide conversational interfaces powered by LLMs. Create agents with custom prompts, connect them to messaging channels (Telegram, Instagram, WhatsApp), and manage chat sessions.

Create Agent

POST /v1/businesses/{businessId}/agents
SDK: sdk.agent.createAgent()
const agent = await sdk.agent.createAgent({
  key: 'support-bot',
  prompt: 'You are a helpful customer support agent for an e-commerce store. Be friendly and concise.',
  modelId: 'gpt-4',
  status: 'active',
  channelIds: ['integration_telegram_123'],
});

Parameters

Name Type Description
key required string Unique agent identifier
prompt required string System prompt that defines agent behavior
modelId required string LLM model ID to use (e.g. gpt-4, claude-3)
status optional active | disabled Agent status (default: active)
channelIds optional string[] Integration IDs for messaging channels
Tip

The model must come from a configured AI integration on the business (OpenAI, DeepSeek). See Integrations.

Get Agent

GET /v1/businesses/{businessId}/agents/{id}
SDK: sdk.agent.getAgent()
const agent = await sdk.agent.getAgent({ id: 'agent_abc123' });

List Agents

GET /v1/businesses/{businessId}/agents
SDK: sdk.agent.getAgents()
const { items, cursor } = await sdk.agent.getAgents({
  limit: 20,
});

Parameters

Name Type Description
limit optional number Items per page
cursor optional string Pagination cursor

Update Agent

PUT /v1/businesses/{businessId}/agents/{id}
SDK: sdk.agent.updateAgent()

All fields other than id are optional — only provided fields are updated.

await sdk.agent.updateAgent({
  id: 'agent_abc123',
  prompt: 'Updated prompt with new instructions...',
  status: 'disabled',
});

Parameters

Name Type Description
id required string Agent ID
key optional string Agent key
prompt optional string Updated system prompt
status optional active | disabled Agent status
modelId optional string LLM model ID
channelIds optional string[] Updated channel integrations

Delete Agent

DELETE /v1/businesses/{businessId}/agents/{id}
SDK: sdk.agent.deleteAgent()

Deletes the agent and all associated chats and messages.

await sdk.agent.deleteAgent({ id: 'agent_abc123' });

Send Message

POST /v1/businesses/{businessId}/agents/{id}/chats/messages
SDK: sdk.agent.sendMessage()

Send a message to an agent. Creates a new chat or continues an existing one.

// Start a new conversation
const response = await sdk.agent.sendMessage({
  id: 'agent_abc123',
  message: 'Hi, I need help with my order',
});

// Continue existing chat
const followUp = await sdk.agent.sendMessage({
  id: 'agent_abc123',
  message: 'Can you check order #12345?',
  chatId: response.chatId,
});

// Direct mode (no chat history, single request/response)
const directResponse = await sdk.agent.sendMessage({
  id: 'agent_abc123',
  message: 'What are your business hours?',
  direct: true,
});

Response:

{
  "response": "Sure, I can help with that...",
  "chatId": "chat_xyz789"
}

Parameters

Name Type Description
id required string Agent ID
message required string User message
chatId optional string Existing chat ID to continue conversation
direct optional boolean Direct mode — no chat history, single exchange

List Chats

GET /v1/businesses/{businessId}/agents/{id}/chats
SDK: sdk.agent.getChats()

List chat sessions for an agent.

const { items, cursor } = await sdk.agent.getChats({
  id: 'agent_abc123',
  limit: 20,
});

Get Chat

GET /v1/businesses/{businessId}/agents/{id}/chats/{chatId}
SDK: sdk.agent.getChat()
const chat = await sdk.agent.getChat({
  id: 'agent_abc123',
  chatId: 'chat_xyz789',
});

Get Chat Messages

GET /v1/businesses/{businessId}/agents/{id}/chats/{chatId}/messages
SDK: sdk.agent.getChatMessages()
const messages = await sdk.agent.getChatMessages({
  id: 'agent_abc123',
  chatId: 'chat_xyz789',
  limit: 50,
});

Update Chat

PUT /v1/businesses/{businessId}/agents/{id}/chats/{chatId}
SDK: sdk.agent.updateChat()

Update chat status (e.g. mark as resolved).

await sdk.agent.updateChat({
  id: 'agent_abc123',
  chatId: 'chat_xyz789',
  status: 'resolved',
});

Rate Chat

POST /v1/businesses/{businessId}/agents/{id}/chats/{chatId}/rate
SDK: sdk.agent.rateChat()

Allow users to rate a chat experience.

await sdk.agent.rateChat({
  id: 'agent_abc123',
  chatId: 'chat_xyz789',
  rating: 5,
  comment: 'Very helpful!',
});

Parameters

Name Type Description
id required string Agent ID
chatId required string Chat ID
rating required number Rating (1-5)
comment optional string Optional feedback comment

List Business Chats

GET /v1/businesses/{businessId}/chats
SDK: sdk.agent.getBusinessChats()

List all chats across all agents for a business. Supports filtering by agent, status, and search query.

const { items, cursor } = await sdk.agent.getBusinessChats({
  agentId: 'agent_abc123',
  status: 'active',
  query: 'refund',
  sortField: 'createdAt',
  sortDirection: 'desc',
  limit: 50,
});

Parameters

Name Type Description
agentId optional string Filter by agent
status optional active | archived Filter by chat status
query optional string Search within chat messages
sortField optional string Sort field (createdAt)
sortDirection optional asc | desc Sort direction
limit optional number Items per page
cursor optional string Pagination cursor