Examples / Workflows
Run an agent task after a submission
Saving the form starts an agent in the background, which reads the submission and saves its answers back to it.
An Agent: Run task action on the form runs a task on the server, with no one waiting. Here, after each new submission is saved, an AI agent reads the message, writes a one-line summary and chooses an urgency (the fields of the form's review task), and the UAG saves them as an update to the submission. Saving that update runs the form's update actions, as any edit would, so it can start another task, send an email or call a webhook.
The criteria text (a content component marked uagField: "criteria") is the agent's instructions. uagEngine: "agent" gives the whole task to a full AI agent instead of the fast decision engine. On the server, a choice field is normally saved only from the decision engine's answer, so uagAgentDecides lets the agent's choice of urgency be saved.
Try it: submit the form and watch the What the UAG did panel. The save comes back at once; then the page checks the saved submission every two seconds until the agent's summary and urgency appear on it. The Action tab shows the action's settings.
Turn it on
{
"title": "Example: Run an agent task after a submission",
"name": "exampleRunTask",
"path": "example-run-task",
"type": "form",
"display": "form",
"tags": [
"uag"
],
"properties": {
"description": "A message, reviewed by an agent after it is saved."
},
"components": [
{
"type": "textfield",
"key": "name",
"label": "Name",
"input": true,
"validate": {
"required": true
}
},
{
"type": "textarea",
"key": "message",
"label": "Message",
"input": true,
"rows": 4,
"validate": {
"required": true
}
},
{
"type": "content",
"key": "reviewCriteria",
"label": "Criteria",
"input": false,
"html": "<p>You review messages sent to a team. Read <code>message</code>. Write <code>summary</code>: one sentence, under 20 words, saying what the sender wants. Set <code>urgency</code> to <code>urgent</code> if work is stopped or a deadline is within two days, <code>low</code> if nothing is blocked, and <code>normal</code> otherwise.</p>",
"properties": {
"uag": "review",
"uagField": "criteria",
"uagEngine": "agent"
}
},
{
"type": "panel",
"key": "review",
"title": "Filled in by the agent after you submit",
"input": false,
"components": [
{
"type": "textfield",
"key": "summary",
"label": "Summary",
"input": true,
"disabled": true,
"properties": {
"uag": "review"
}
},
{
"type": "radio",
"key": "urgency",
"label": "Urgency",
"input": true,
"values": [
{
"label": "Low",
"value": "low"
},
{
"label": "Normal",
"value": "normal"
},
{
"label": "Urgent",
"value": "urgent"
}
],
"disabled": true,
"properties": {
"uag": "review",
"uagAgentDecides": "true"
}
}
]
},
{
"type": "button",
"key": "submit",
"label": "Submit",
"action": "submit",
"input": true
}
]
}<link rel="stylesheet" href="https://ai.form.io/uag-js/uag-js.css">
<script src="https://cdn.jsdelivr.net/npm/@formio/js@5.6.1/dist/formio.full.min.js"></script>
<!-- Registers @formio/uag-js with this UAG: forms tagged uag save through it, and get Agent Input and the chat. -->
<script src="https://ai.form.io/uag-js/uag.use.js"></script>
<div id="form"></div>
<script>
Formio.createForm(document.getElementById('form'), 'https://uag.form.io/example-run-task');
</script>{
"title": "Agent: Run task (review)",
"name": "agentRunTask",
"priority": 20,
"handler": [
"before",
"after"
],
"method": [
"create"
],
"settings": {
"task": "review",
"answer": "task",
"when": "after"
}
}Try it
Start the live examples
The examples call real models. Starting them signs you in as a temporary guest of the examples' project, for every example; what you enter is deleted after a day.
Not supported without a license
This demo needs a license (LICENSE_KEY) that includes the UAG, or a 30-day free trial project on portal.form.io. This deployment has neither: it serves an Open Source project, or its UAG is unlicensed.
The chat widget examples work everywhere, with no license.