Skip to Content
AppsVibe Coding6. Agent integrationsRun an agent from your app's UI

Run an agent from your app’s UI

By the end of this page you will have a button in your app that runs one of your agents and shows its answer on the page.

The example used throughout is a simple notes app. A Note Summarizer Task Agent takes a note’s text and returns a two-sentence summary, and the note editor gets a button that runs it.

Prerequisites

  • An app workspace with an active chat session (The generation flow).
  • An active AI or Task Agent in the same project, without a human approval step (Which agents you can use).
  • For a Task Agent, its End node’s Output Mapping defines what your app receives. An agent that maps one output, such as summary, hands your app that value directly. See End node.

Steps

Choose Agent Action and an agent

Open the integration dialog (see Open the integration dialog). Under Integration Type, click Agent Action (The browser calls it), then pick your agent under Select Agent.

Describe the action

FieldWhat to enterExample
PurposeWhat the action does. It also names the integration, so it can’t be changed later.Summarize the note
Trigger LocationWhere the control should go, in plain wordsnext to the Save button on the note editor
Allowed RolesWhich of your app’s roles may run it. Leave it empty for any signed-in user.Editor
Execution ModeWait for result or Stream progress. Both deliver the result to the app.Wait for result
The Agent Action form with Purpose, Trigger Location, Allowed Roles set to Editor, Execution Mode set to Wait for result, and Trigger set to On click (button)

Allowed Roles only appears as a choice when your app has sign-in turned on, and it lists the roles your app declares. If the app has no sign-in, the field explains that there’s no signed-in user to check a role against.

💡

Choose Stream progress for an agent that may take longer than about 50 seconds. With Wait for result, a published app stops waiting after that, before the result arrives.

Choose what triggers it

TriggerWhat happens in your app
On click (button)A button runs the agent. This is the default.
On page loadThe agent runs when the page opens.
On field changeThe agent runs shortly after a field stops changing. Name the field in Trigger Field, for example form.customerId.
Interval (poll)The agent runs straight away, then repeats every Interval (ms). The default is 30000 (30 seconds).

Map the agent’s inputs

Input Sources lists every input the agent declares, one row each. For each, choose where its value comes from when someone uses the app:

SourceUse it for
What the user typesText the person enters for this action
Something on the pageA value already on the page, such as a form field
From the URL pathPart of the page’s address, such as an id in /notes/42
From the URL queryA query parameter, such as ?status=open
The selected itemThe row or card the person has selected
The signed-in userA detail of the person who is signed in
A fixed valueThe same value every time. Type it in the box.

Most sources have a second box. For A fixed value it holds the value itself; for the others it names the value to read, and defaults to the input’s own name. What the user types has no second box. In the example, the agent’s text input comes from Something on the page, with body as the value: the note’s body field.

Input Sources with the text input mapped to Something on the page, value body, and Output Display set to Inline text
ℹ️

An AI Agent has a single input, message. Map whatever the agent should act on, such as the note’s text, to message.

Choose how the result appears

Pick an Output Display:

DisplayWhat it showsWorks with
Auto (fallback)qRaptor picks a layout from the shape of the agent’s outputAI and Task Agents
Inline textThe result as a line of text on the pageAI and Task Agents
CardThe result in a bordered card. Suits an agent that returns several values.AI and Task Agents
Streamed textThe agent’s reply appearing as it’s written, from a Prompt Template you writeAI Agents
Streamed chatA small chat panel with the agentAI Agents

For a single piece of text, like the example’s summary, choose Inline text.

The Output Display set to Inline text, with the note that Streamed text and Streamed chat need an AI agent

Add the integration

Click Add Integration. The request appears in the chat panel as an Agent Integration card, and qRaptor builds it like any other change.

The chat panel showing the qRaptor Architect — Agent Integration card for the Note Summarizer action

Try it in the preview

When the build finishes, open the Preview tab. If your app has sign-in, sign in with a role that’s allowed to run the action (see Preview your app).

With the On click (button) trigger, the page gets a button where you described it — in this example, Summarize, next to Save Changes. The button is disabled while the agent runs.

The note editor in preview, with the Summarize button next to Save Changes and Delete

Click it. The result appears in the display you chose — here, the summary on the note editor.

The two-sentence summary shown on the note editor after clicking Summarize

What qRaptor builds

  • The call to the agent. qRaptor writes this code itself, so it isn’t generated fresh, and it’s rebuilt whenever the integration changes. It sends the mapped inputs, waits for or follows the run, and hands the result to the page.
  • The control and the result. The button or page event, and the display you chose, are added to the page you described. The rest of the page’s layout and wording is generated as usual.
  • The connection to the agent. Your app is allowed to call this agent, and only this agent, through this integration. Calls go to the agent’s production version.

If a call can’t complete, the person using your app sees a short message in place of the result:

MessageWhat it means
You are not permitted to run this action.They don’t hold any of the Allowed Roles
This agent is not available in this app.The agent no longer has a production version, or isn’t connected to this app
This workspace is out of credits. Top up the subscription to run this action.The workspace has run out of credits
Too many requests right now — please try again in a moment.Too many calls in a short time
The agent run failed.The agent ran but didn’t succeed. If the agent reported an error, that message is shown instead.

Common issues

  • There’s no Input Sources section. The agent declares no inputs, so there’s nothing to map.
  • Streamed text and Streamed chat are greyed out. They need an AI Agent. To follow a Task Agent’s run, set Execution Mode to Stream progress instead.
  • The result shows {} or a block of text with braces. The agent returns several values, or none. Check the Output Mapping on its End node, and choose Card to show several values.
  • Some people can’t run the action. They see You are not permitted to run this action., or the control is disabled for them, because they don’t hold one of the Allowed Roles. Sign in with an allowed role to check.
  • An AI Agent’s answer ignores the page. Its message input isn’t mapped to the content it should act on. Edit the integration and map it (see Edit or remove an integration).