Zum Hauptinhalt springen

Dynamic Form

In questa sezione


Request

{
"userQuestion": {
"userId": "userId",
"botId": "botId",
"conversationId": 832764,
"question_text": "the user question input"
},
"intent" : {
"intentId": 1234,
"botId": "botId",
"name": "Intent name",
"questions": [
{
"questionText": "the question text"
}
],
"answers": [
{
"answerText": "The answer text",
"mediaType": "link",
"media": "https://wwww.google.com",
"answerType": "QA",
"chosen": true
}
]
},
"answers": [
{
"answerText": "The answer text",
"mediaType": "link",
"media": "https://wwww.google.com",
"answerType": "QA"
}
],
"previousMessages": [
{
"userQuestion": "Hey bot",
"botMessageText": "Hey user"
}
],
"metadata": {
"a": "b"
},
"formInstanceId": "2135",
"formInstanceStatus": "INCOMPLETE",
"validationResult": "XXXXXX",
"previousValues": [
// see description
],
"autofilled": false,
"skipped": false,
"interrupted": false
}

Details

User question

Contains the user query, along other informations.

FieldDescriptionNotes
userIdthe user idalways present
botIdthe bot idalways present
conversationIdthe conversation idit can be null on first message from the user to the bot
currentUrlthe URL from which the message was sentoptional, nullable
questionIdthe intent ID specified in the messageoptional, nullable
inputTypethe type of inputoptional, nullable
sourcethe source of the messageoptional, nullable
applicationContextthe context of the messageoptional, nullable
wsBasePaththe base path of the WSoptional, nullable
question_textthe user question textalways present

Intent

If the dynamic form was invoked by an intent, this field will be present. The fields are self-explanatory, the other things to know are:

  • if an intent has more than one answer, the matched one (by Algho responder) will have chosen set as true
  • the answer type can be:
    • QA, meaning a found answer
    • QB, meaning a not found answer
    • QD, a disambiguation
  • the media type can be:
    • img, meaning the media field will need to contain a link/base64 image
    • link, meaning the media field will contain an URL to a web page
    • video, the same as the image but for videos

Answers

The answers field will hold the answer found by the responder before calling the WS. See above.

Messages

It will holds the messages in the conversation exchanged by the user with the bot. This will be present only in the first call to the WS starting the form.

Metadata

It will hold a custom json set from a response from the WS. In the first call it will be the wsMetadata set in the answer (both from the intent answer or the quibble). The WS must populate this field accordingly, as it will be null unless set from the WS.

formInstanceId

A unique identifier of the form instance.

formInstanceStatus

The form instance status, it can be:

ValueDescription
INCOMPLETEThe form is incomplete. This is the starting status.
SUCCESSThe form is completed with success.
FAILEDThe form is failed due to user error.
INTERNAL_FAILThe form is failed due to a WS error.

In the request it will only be INCOMPLETE. The other states will be used in the response.

validationResult

This key, only present in the requests after the first, will hold the validation performed by Algho on the field gave to the user. For example, in the case of date field gave to the user may hold (if found) the normalized value of the date specified by the user. If validation is failed (i.e. no valid date is given from the user) this key will be empty or not in the request.

previousValues

It will hold field history sent in subsequent response (see response description). In the first request it will be null.

autofilled

If the core extracted some values from the previous user question this flag will be true

skipped

If true it means that the user skipped the previous field

interrupted

If true it means that the user clicked on the option to interrupt the form.

The web service can use this information to give one ore more custom messages using the answers in the response and to do internal operation.

In case of no answers in the response nothing will be shown to the user.

Response

{
"answers": [
{
"answerText": "The answer text",
"mediaType": "link",
"media": "https://wwww.google.com",
"answerType": "QA"
}
],
"formStatus": "INCOMPLETE",
"formName": "The custom form name",
"fieldTemplate": {
// check the description below
},
"nextEndpoint": "https://www.google.com",
"metadata": { /* see the request example */ },
"values": [
// optional, see description
]
}

Details

answers

It will hold the answers to be shown to the user, see the request details for the format as it's the same.

formInstanceStatus

If not set to INCOMPLETE it will end the form accordingly to the specified status.

formName

If set it will be used in the algho form data for history purpose, otherwise it will be autogenerated.

fieldTemplate

The field shown to the user:

FieldDescriptionNotes
fieldTypeThe type of the field to be shown to the userSee the table below for the types
questionTextThe question to be send to the userMandatory
maxValuesToSelectThe max number of admissible values (if present) to be shownOptional, default 1
disableWritingIf the text input box must be enabled or notOptional, deafult false
showInFullscreenIf the admissible values must be shown in fullscreenOptional, default false
skippableIf the user can skip the fieldRequired
interruptableIf the user can abort the formRequired
admissibleValuesMandatory admissible values for the user, they can be optional - Array of possible valuesOptional

Field type description

KeyDescription
TextFieldTypeis a plain text
EmailFieldTypeis an email address
NumFieldTypeis a number (only digits allowed)
AreaCodeFieldTypeis an area code number (eg. +39, +34, +442 etc.)
TelFieldTypeis a phone number
LocationFieldTypeis an address
PostalCodeFieldTypeis a postal code
DateFieldTypeis a date (yyyy-MM-dd) or a date is extracted from text
BirthDateFieldTypeis a date in the past (yyyy-MM-dd)
BookingDateFieldTypeis a date in future, starting from today (yyyy-MM-dd)
DayFieldTypeis a day (Monday, Tuesday etc.), depends on form language
HourFieldTyperepresents an hour (HH:mm)
DateHourFieldTypeis both a day and a date (yyyy-MM-dd HH:mm)
DateRangeFieldTypeis a range of dates (yyyy-MM-dd - yyyy-MM-dd)
DayRangeFieldTypeis a range of days (Monday - Friday)
HourRangeFieldTypeis a range of hours (HH:mm - HH:mm)
BoolFieldTypeis a choice between TRUE of FALSE
NameFieldTypeis a name or a name is extracted from text
SurnameFieldTypeis a surname or a surname is extracted from text
FullNameFieldTypeis a name and surname or a name and surname are extracted from text
CFFieldTypeis a tax code
VatFieldTypeis a VAT number
UrlFieldTypeis an URL
FileFieldTypeis the URL of a file uploaded by the user
AudioFieldTypeis the URL of an audio recorded by the user
QRCodeFieldTypeis the content of a QR code scanned by the user
SPIDFieldTypeare the content of a successful SPID login
PasswordFieldTyperepresents a password, it will be hashed one-way and is not reversible
PrivacyFieldTypeis a BoolFieldType dedicated to the privacy consent (eg. service, marketing, profiling, etc.)
BusinessFieldTypeis the name of a business, or what is extracted as the name of a business
CatalogFieldType
CurrencyFieldTyperapresents a currency (eg. €, $, £, ¥)
MeasureFieldTypeis a measurable normalized quantity (eg. "5 kg", "15 mA")
QuantityFieldTypeis a non-normalized quantity (eg. "5 grams")
OrderFieldTypeis the ID of an existing order

Admissible value will have two keys, "name" and "alias": "name" field will be the name of the valid value (mandatory field) displayed in the interface, while the "alias" field will be the alias of the displayed name (not mandatory). The "alias" field can contain several synonyms of the name, separated by a comma.

nextEndpoint and metadata

Will hold the next endpoint to call if the form it's not over. The metadata if present will be set for the next calls to the WS.

values

It will save the values in the field history in Algho. Values saved will be in the same format in subsequent requests

FieldDescriptionNotes
fieldTypeThe type of the fieldSee the table above
valueThe value savedMandatory
nameThe name of the field to be savedOptional, default random
externalIdThe external idOptional, default null
admissibleValuesThe admissible valuesOptional, see above