Examples menu

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

json
{
  "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
    }
  ]
}

Try it

Samples:
Example: Run an agent task after a submission

Read about it in the developer docs