Skip to Content

Build AI Agents

An AI Agent is a reusable AI capability in Momen. It accepts data from a page, an Actionflow, or the Runtime API; combines that data with prompts, contexts, and tools; and returns text, structured data, images, or other model output.

For a one-off task, start a conversation and use the result. For an ongoing conversation, keep the conversation ID and use it to continue the conversation, stop a response, or delete the conversation.

Use cases

  • Generate, rewrite, summarize, or classify content from user input.
  • Answer questions using project data, such as in a knowledge assistant or customer-support experience.
  • Let a model call APIs, Actionflows, or other Agents when needed.
  • Return a fixed data structure for conditions, database operations, or UI binding.
  • Generate or process images, video, and other media.

Build an Agent

Create an Agent

Open Action → Agent, then create an Agent with a descriptive name.

When you create the first Agent, Momen automatically creates Conversation, Message, Message Content, and Tool Usage Record tables for runtime data. See Runtime data.

Choose a model and tune its settings

Choose a model that supports the capabilities your task needs. Support for multimodal input, streaming, structured output, reasoning content, and tools varies by model. The editor shows the settings available for the selected model.

Common settings include:

  • Temperature: Higher values generally produce more varied output. Use a lower value when results need to be stable and repeatable.
  • Max turns: Limits the number of turns in one conversation.
  • Token limit per turn: Limits a single response. Reaching the limit may produce an incomplete result or fail the turn.
  • Image processing mode: Selects the processing detail when the model accepts images. Detailed processing usually consumes more tokens.

Conversation history is included in later turns. Longer conversations and messages generally increase context size and AI Point usage.

Define inputs

Inputs define the dynamic values supplied each time the Agent runs, such as a user question, article content, record ID, or image.

  • Text, numbers, and similar inputs can be referenced in prompts and contexts.
  • Image and video inputs are appended to the prompt automatically and cannot be inserted as variables in the prompt text.
  • If an input name or type is already used by a page, Actionflow, or Runtime API client, update every caller before changing it.

Use inputs only for values that change between calls. Put fixed roles, rules, and output requirements in the system prompt.

Write prompts

  • System prompt: Define the Agent’s role, objective, business rules, constraints, and output requirements.
  • Initial user message: Define the first user message sent when a conversation starts. Some models require this field.

State the task, available information, prohibited operations, and expected result clearly. Bind configured inputs from the data-binding panel instead of typing variable paths manually.

Add contexts

Contexts retrieve data related to the current request and send it to the model with the prompts. A context can use the Momen database or an API as its data source.

Confirm the following when configuring a context:

  • Which value is used for retrieval.
  • Which data source and fields are searched.
  • How many results are returned.
  • Whether permissions and filters limit what the current user can access.

Since August 2025, new file-upload contexts are no longer supported. Existing file contexts continue to work. To use file content, preprocess it into the Momen database or retrieve it through an API backed by a third-party RAG service.

For vector storage and semantic search, see Vector data.

Add tools

An Agent can use the following as tools:

  • Actionflows
  • APIs
  • Other Agents

The model decides whether to call a tool and what arguments to pass based on the conversation and the tool description. Give each tool a clear name and description that explains its purpose, when to use it, its inputs, and its result. Avoid tools with overlapping responsibilities.

⚠️

Tools can modify data, call external services, or produce other side effects. For operations such as creating an order or sending a notification, enforce permissions, validate inputs, and implement idempotency in the underlying Actionflow or API. Do not rely on the prompt as a security boundary.

Choose an output format

Choose an output type based on how the result will be used:

  • Plain text: Best for natural-language content displayed directly to users. Streaming can be enabled.
  • Structured: Returns the configured fields for data binding, conditions, or database operations. Use stable field names and add a precise description for each field.

Not every model supports streaming or structured output. After changing models, review the output format and test the Agent again.

While content is streaming, it can be displayed on a page but cannot be used as data by later operations. After the Agent finishes, the complete result is available to subsequent steps.

Test the Agent

In Debug, provide test values for the Agent inputs and run it. Verify that:

  • Inputs are referenced correctly in the prompts.
  • Contexts retrieve the expected data.
  • The model calls the right tools with valid arguments, and the tool responses are correct.
  • The result matches the selected plain-text or structured-output format.
  • A mock user is selected when the Agent uses Current User data.

Test normal input, empty or boundary input, and failures such as an unavailable tool. For structured output, also check for missing fields and inconsistent types.

Publish the Agent

Agent changes are saved automatically but must be published before they take effect at runtime. Both Update preview and Sync changes publish the latest Agent, Actionflow, API, and other backend changes. Update preview also refreshes the frontend preview.

Publishing an Agent affects live apps immediately. When changing inputs, outputs, models, prompts, or tools, check that published pages, Actionflows, and Runtime API clients remain compatible.

Use an Agent

You can use an Agent from a page, an Actionflow, or the Runtime API. The entry point differs, but conversation and result handling work the same way.

OperationPurposeKey settings
Start conversationCreate a conversation and run the AgentAgent and Agent inputs
Continue conversationSend another message in an existing conversationAgent, conversation ID, and text or media content
Stop responseStop the response currently being generatedAgent and conversation ID
Delete conversationDelete a conversation and its related messagesAgent and conversation ID
  • Page or component: Add the corresponding action from AI under a trigger. These actions support On success and On failure branches, and Show loading animation on request controls the default loading state.
  • Actionflow: Add the corresponding node from AI and combine it with database, API, condition, or For each nodes. An Actionflow that contains an AI Agent node must use asynchronous execution. See Build Actionflows.
  • Runtime API: Start conversations, listen for results, and manage messages in code. See Runtime API Reference — AI Agents.

One-off tasks

For tasks such as summarization, classification, or single-response generation:

  1. Add a Start conversation action or node.
  2. Select the Agent and bind caller data to its inputs.
  3. After the Agent completes, use its result in subsequent actions or nodes.
  4. Add an appropriate error message, retry, or other failure handling for the calling environment.

Plain-text output returns text. Structured output exposes the configured fields for later data binding. For image-generation models, use the image data returned by the operation to display or store the result.

Multi-turn conversations

Keep using the same conversation ID throughout a multi-turn conversation:

  1. Use Start conversation and store the returned conversation ID.
  2. For later messages, use Continue conversation with the stored ID.
  3. Use Stop response when the current generation needs to be interrupted.
  4. Use Delete conversation when the conversation no longer needs to be retained.
⚠️

Do not start a new conversation for each follow-up message. Doing so creates a different conversation without the previous context.

Display streaming output on a page

When streaming is enabled, assign streaming content from Start conversation or Continue conversation to a text page variable, then bind that variable to a text component. The variable updates while the response is generated. Use the final result from On success when the complete content needs to be stored or processed further.

Models and AI Points

Momen provides system models and supports Bring Your Own Model (BYOM) on paid projects. Depending on the provider and model type, BYOM configuration may require an API key, service URL, authentication header, or model ID. Validate the model details, save them, and publish before use.

Model capabilities vary. Use the capability indicators and settings shown in the editor instead of assuming that a model supports images, video, structured output, or tools based on its name alone.

Model calls and vector features consume AI Points. When the balance is insufficient, Agent calls, vectorization, or vector search may fail. Check balances and usage in project details. For plan quotas and resource packs, see Manage Project Resources.

Runtime data

Creating an Agent automatically creates these system tables:

TableWhat it records
ConversationInitiating user, Agent settings, model, status, and error information
Messagesystem, user, and assistant messages in a conversation
Message ContentText, image, video, PDF, audio, JSON, or reasoning content, plus token usage
Tool Usage RecordTool name and type, request, response, and related message

Use these tables to query conversation status, display history, and troubleshoot runs. Rows cannot be added to these system tables manually; Momen writes the corresponding records when Agent operations run.

Common issues

  1. The Agent works in Debug but fails when called: Check that the Agent is published, bound input types still match its inputs, the selected model is available, and the project has enough AI Points. If the Agent uses tools, verify that each Actionflow, API, or Agent is published and receives valid arguments.
  2. Structured output is missing fields or changes shape: Give every output field a clear name and description, list required fields in the system prompt, remove conflicting format instructions, and confirm that the selected model supports structured output.
  3. The selected model has been retired: An Agent using a retired model cannot be tested or published, and live calls fail. Switch to an available model, review capability differences, test the Agent, and publish it again.
  4. A tool is not called or the wrong tool is selected: Clarify tool names and descriptions, make sure required arguments are available from the conversation, and remove overlapping responsibilities. The model decides whether to call a tool; put mandatory business steps in an Actionflow instead of relying on model choice.
Last updated on