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
{
"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
}
]
}<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="chat"></div>
<script>
Formio.createChat(document.getElementById('chat'), 'https://uag.form.io/example-chat-widget');
</script>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.