Examples menu

Examples / Chat widget

Chat widget

Any form the UAG can fill can be filled in as a chat: the widget asks for what the form needs, then submits it once the person confirms.

One call in the page code, Formio.createChat, shows a form as a chat. After each message, the UAG fills in what it can and asks for what is still missing. The questions come from the form: its fields, labels, descriptions, options and validation. When the form is complete, the widget shows a summary, and the person confirms before it is submitted, through the UAG, like any other submission.

uagChatInstructions adds instructions of your own. This form's ask the chat to be brief and friendly, ask for one thing at a time, and use the person's name. You can change the widget's text, buttons and styles.

Try it: type a message, or pick a sample to start.

Turn it on

json
{
  "title": "Example: Chat widget",
  "name": "exampleChatWidget",
  "path": "example-chat-widget",
  "type": "form",
  "display": "form",
  "tags": [
    "uag"
  ],
  "properties": {
    "description": "A general request: who sent it, how to reach them, what it is about, and the details.",
    "uagChatInstructions": "Be brief and friendly. Ask for one thing at a time, and use the person's name once you know it."
  },
  "components": [
    {
      "type": "textfield",
      "key": "name",
      "label": "Name",
      "input": true,
      "validate": {
        "required": true
      }
    },
    {
      "type": "email",
      "key": "email",
      "label": "Email",
      "input": true,
      "validate": {
        "required": true
      }
    },
    {
      "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
      }
    },
    {
      "type": "textarea",
      "key": "details",
      "label": "Details",
      "input": true,
      "rows": 3,
      "validate": {
        "required": true
      },
      "description": "What you need, in a sentence or two."
    },
    {
      "type": "button",
      "key": "submit",
      "label": "Submit",
      "action": "submit",
      "input": true
    }
  ]
}

Try it

Samples:
Example: Chat widget

Read about it in the developer docs