Skip to content

Bot Endpoints

Learn how to integrate bots in OI Agents.

API Integration

For programmatic integration with your applications, bots use conversations as the primary interface. You can find integration examples with code snippets under the "Share" tab inside your RAG bot.

Integration Workflow

The basic workflow for integrating with a bot involves two main steps:

  1. Create a Conversation - Initialize a new conversation session
  2. Stream Chat - Send messages and receive responses

Step 1: Create a Conversation

First, you need to create a conversation using the create conversation endpoint:

Endpoint: ${baseUrl}/app/rag_conversation/add

Method: POST

Headers:

Authorization: Bearer {api_key}
Content-Type: application/json

Request Body:

{
  "bot_id": "[BOT_ID_PLACEHOLDER]",
  "name": "[CONVERSATION_NAME_PLACEHOLDER]"
}

Parameters:

  • bot_id - The unique identifier of the bot you want to create a conversation with
  • name - A descriptive name for the conversation

Response:

{
  "id": string,
  "bot_id": string,
  "name": string,
  "queries": Array<ConversationQuery>,
  "created_at": string,
  "updated_at": string,
  ...other metadata
}

Step 2: Stream Chat

Once you have a conversation ID, you can send messages using the stream chat endpoint:

Endpoint: ${baseUrl}/rag/stream_answer

Method: POST

Headers:

Authorization: Bearer {api_key}
Content-Type: application/json

Request Body:

{
  "bot_id": "[BOT_ID_PLACEHOLDER]",
  "question": "[USER_QUESTION]",
  "conversation_id": "[CONVERSATION_ID_FROM_STEP_1]",
  "debug_mode": false,
  "web_search": false
}

Parameters:

  • bot_id - The unique identifier of the bot you want to interact with
  • question - The user's message or question to send to the bot
  • conversation_id - The conversation ID obtained from the create conversation endpoint
  • debug_mode - Boolean flag to enable debugging information in the response (optional, default: false)
  • web_search - Boolean flag to enable web search capabilities for the bot response (optional, default: false)

Important Notes

  • Each conversation maintains its own context and history