Examples menu

Examples / Fill in forms

Fill a form from a description

A person describes what they need in their own words, and the form's other fields fill themselves in from it.

Agent Input, part of the UAG's browser library @formio/uag-js, reads what the person wrote in one field (Describe your request) and fills in the rest of the form from it. You choose which fields it fills by giving each one the same task name in its uag property (here fill), and you mark the field to read with uagField: "input".

The AI only fills the fields in; the person can change any of them. Nothing is saved until the person checks the form and submits it, and the form's own validation applies to every value, whoever entered it.

Try it: type a request and click outside the box, or pick a sample, to see the form fill in. The What the UAG did panel beside the form shows the request to the UAG and what the AI returned for each field.

Turn it on

json
{
  "title": "Example: Fill a form from a description",
  "name": "exampleFillFromDescription",
  "path": "example-fill-from-description",
  "type": "form",
  "display": "form",
  "tags": [
    "uag"
  ],
  "properties": {
    "description": "A general request: who sent it, when, what it is about, and the amount involved, filled in from the sender's own description."
  },
  "components": [
    {
      "type": "textarea",
      "key": "description",
      "label": "Describe your request",
      "placeholder": "Tell us what you need, in your own words.",
      "rows": 4,
      "input": true,
      "validate": {
        "required": true
      },
      "properties": {
        "uag": "fill",
        "uagField": "input"
      }
    },
    {
      "type": "textfield",
      "key": "name",
      "label": "Name",
      "input": true,
      "validate": {
        "required": true
      },
      "properties": {
        "uag": "fill"
      }
    },
    {
      "type": "email",
      "key": "email",
      "label": "Email",
      "input": true,
      "validate": {
        "required": true
      },
      "properties": {
        "uag": "fill"
      }
    },
    {
      "type": "select",
      "key": "topic",
      "label": "Topic",
      "input": true,
      "dataSrc": "values",
      "data": {
        "values": [
          {
            "label": "Question",
            "value": "question"
          },
          {
            "label": "Problem",
            "value": "problem"
          },
          {
            "label": "Request",
            "value": "request"
          },
          {
            "label": "Feedback",
            "value": "feedback"
          }
        ]
      },
      "validate": {
        "required": true
      },
      "properties": {
        "uag": "fill"
      }
    },
    {
      "type": "day",
      "key": "date",
      "label": "Date it happened",
      "input": true,
      "properties": {
        "uag": "fill"
      }
    },
    {
      "type": "currency",
      "key": "amount",
      "label": "Amount involved",
      "currency": "USD",
      "input": true,
      "properties": {
        "uag": "fill"
      }
    },
    {
      "type": "button",
      "key": "submit",
      "label": "Submit",
      "action": "submit",
      "input": true
    }
  ]
}

Try it

Samples:
Example: Fill a form from a description

Read about it in the developer docs