Agents module for managing AI agent conversations. This module provides methods to create and manage conversations with AI agents, send messages, and subscribe to real-time updates. Conversations can be used for chat interfaces, support systems, or any interactive AI app. The agents module enables you to:
- Create conversations with agents defined in the app.
- Send messages from users to agents and receive AI-generated responses.
- Retrieve conversations individually or as filtered lists with sorting and pagination.
- Subscribe to real-time updates using WebSocket connections to receive instant notifications when new messages arrive.
- Attach metadata to conversations for tracking context, categories, priorities, or linking to external systems.
- Generate WhatsApp connection URLs for users to interact with agents through WhatsApp.
- Conversations: Top-level containers that represent a dialogue with a specific agent. Each conversation has a unique ID, is associated with an agent by name, and belongs to the user who created it. Conversations can include optional metadata for tracking app-specific context like ticket IDs, categories, or custom fields.
- Messages: Individual exchanges within a conversation. Each message has a role, content, and optional metadata like token usage, tool calls, file attachments, and reasoning information. Messages are stored as an array within their parent conversation.
- Anonymous or User authentication (
base44.agents): Access is scoped to the current user’s permissions. Anonymous users can create conversations but can’t retrieve them later, while authenticated users can access conversations they created. - Service role authentication (
base44.asServiceRole.agents): Operations have elevated admin-level permissions. Can access all conversations that the app’s admin role has access to.
Methods
getConversations()
getConversations():Gets all conversations from all agents in the app. Retrieves all conversations. UsePromise<AgentConversation[]>
listConversations() to filter which conversations are returned, apply sorting, or paginate results. Use getConversation() to retrieve a specific conversation by ID.
Returns
AgentConversation
An agent conversation containing messages exchanged with an AI agent.
Properties
Properties
Unique identifier for the conversation.
Application ID.
Name of the agent in this conversation.
ID of the user who created the conversation.
When the conversation was created.
When the conversation was last updated.
Array of messages in the conversation.
Properties
Properties
Unique identifier for the message.
Role of the message sender.
When the message was created.
When the message was last updated.
Message content.
URLs to files attached to the message.
Tool calls made by the agent.
Whether the message is hidden from the user.
Model used to generate the message.
Checkpoint ID for the message.
Additional custom parameters for the message.
Optional metadata associated with the conversation.
Example
See
listConversations()for filtering, sorting, and paginationgetConversation()for retrieving a specific conversation by ID
getConversation()
getConversation(Gets a specific conversation by ID. Retrieves a single conversation using its unique identifier. To retrieve all conversations, useconversationId):Promise<AgentConversation|undefined>
getConversations() To filter, sort, or paginate conversations, use listConversations().
Parameters
The unique identifier of the conversation.
Returns
AgentConversation
An agent conversation containing messages exchanged with an AI agent.
Properties
Properties
Unique identifier for the conversation.
Application ID.
Name of the agent in this conversation.
ID of the user who created the conversation.
When the conversation was created.
When the conversation was last updated.
Array of messages in the conversation.
Properties
Properties
Unique identifier for the message.
Role of the message sender.
When the message was created.
When the message was last updated.
Message content.
URLs to files attached to the message.
Tool calls made by the agent.
Whether the message is hidden from the user.
Model used to generate the message.
Checkpoint ID for the message.
Additional custom parameters for the message.
Optional metadata associated with the conversation.
Example
See
getConversations()for retrieving all conversationslistConversations()for filtering and sorting conversations
listConversations()
listConversations(Lists conversations with filtering, sorting, and pagination. Provides querying capabilities including filtering by fields, sorting, pagination, and field selection. For cases where you need all conversations without filtering, usefilterParams):Promise<AgentConversation[]>
getConversations(). To retrieve a specific conversation by ID, use getConversation().
Parameters
Filter parameters for querying conversations.
Properties
Properties
Query object with field-value pairs for filtering.
Sort parameter. For example, “-created_date” for descending order.
Alternative sort parameter. Use either
sort or sort_by.Maximum number of results to return.
Number of results to skip. Used for pagination.
Array of field names to include in the response.
Returns
AgentConversation
An agent conversation containing messages exchanged with an AI agent.
Properties
Properties
Unique identifier for the conversation.
Application ID.
Name of the agent in this conversation.
ID of the user who created the conversation.
When the conversation was created.
When the conversation was last updated.
Array of messages in the conversation.
Properties
Properties
Unique identifier for the message.
Role of the message sender.
When the message was created.
When the message was last updated.
Message content.
URLs to files attached to the message.
Tool calls made by the agent.
Whether the message is hidden from the user.
Model used to generate the message.
Checkpoint ID for the message.
Additional custom parameters for the message.
Optional metadata associated with the conversation.
Examples
See
getConversations()for retrieving all conversations without filteringgetConversation()for retrieving a specific conversation by ID
createConversation()
createConversation(Creates a new conversation with an agent.conversation):Promise<AgentConversation>
Parameters
Conversation details including agent name and optional metadata.
Properties
Properties
Returns
AgentConversation
An agent conversation containing messages exchanged with an AI agent.
Properties
Properties
Unique identifier for the conversation.
Application ID.
Name of the agent in this conversation.
ID of the user who created the conversation.
When the conversation was created.
When the conversation was last updated.
Array of messages in the conversation.
Properties
Properties
Unique identifier for the message.
Role of the message sender.
When the message was created.
When the message was last updated.
Message content.
URLs to files attached to the message.
Tool calls made by the agent.
Whether the message is hidden from the user.
Model used to generate the message.
Checkpoint ID for the message.
Additional custom parameters for the message.
Optional metadata associated with the conversation.
Example
addMessage()
addMessage(Adds a message to a conversation. Sends a message to the agent and updates the conversation. This method also updates the real-time socket to notify any subscribers.conversation,message):Promise<AgentMessage>
Parameters
Properties
Properties
The conversation to add the message to.
Properties
Properties
Unique identifier for the conversation.
Application ID.
Name of the agent in this conversation.
ID of the user who created the conversation.
When the conversation was created.
When the conversation was last updated.
Array of messages in the conversation.
Properties
Properties
Unique identifier for the message.
Role of the message sender.
When the message was created.
When the message was last updated.
Message content.
URLs to files attached to the message.
Tool calls made by the agent.
Whether the message is hidden from the user.
Model used to generate the message.
Checkpoint ID for the message.
Additional custom parameters for the message.
Optional metadata associated with the conversation.
The message to add.
Properties
Properties
Unique identifier for the message.
Role of the message sender.
When the message was created.
When the message was last updated.
Message content.
URLs to files attached to the message.
Tool calls made by the agent.
Whether the message is hidden from the user.
Model used to generate the message.
Checkpoint ID for the message.
Additional custom parameters for the message.
Returns
AgentMessage
A message in an agent conversation.
Properties
Properties
Unique identifier for the message.
Role of the message sender.
When the message was created.
When the message was last updated.
Message content.
URLs to files attached to the message.
Tool calls made by the agent.
Whether the message is hidden from the user.
Model used to generate the message.
Checkpoint ID for the message.
Additional custom parameters for the message.
Example
subscribeToConversation()
subscribeToConversation(Subscribes to real-time updates for a conversation. Establishes a WebSocket connection to receive instant updates when new messages are added to the conversation. Returns an unsubscribe function to clean up the connection.conversationId,onUpdate?): () =>void
Parameters
Properties
Properties
Returns
Unsubscribe function to stop receiving updates.
(): void
Example
getWhatsAppConnectURL()
getWhatsAppConnectURL(Gets WhatsApp connection URL for an agent. Generates a URL that users can use to connect with the agent through WhatsApp. The URL includes authentication if a token is available.agentName):string
Parameters
The name of the agent.
Returns
string
WhatsApp connection URL.

