Forms
Forms is a feature integrated into AI chatbot that allows you to collect structured information from your users. When attached to bot responses, these forms allow end-users to input data into predefined fields, such as email, phone number, name, and more. This functionality not only enhances the efficiency of the interaction but also ensures that the information gathered is organized and specific. This page outlines the process for integrating forms into your app and it focuses on creating and managing custom responses with forms, detecting form-type messages, and handling user input.
Creating custom responses with forms
Using Platform API, you can create a custom response containing from fields that can be attached to bot messages. The request body should include the form structure and fields.
HTTP request
Connecting custom response and bot
Using Platform API, you can associate a custom response with a specific bot using this API call. The custom_response_ids
array should include the ID(s) of the custom responses created in step 1.
HTTP request
Handling forms
This section guides on how to detect form type messages, save and validate user input, and submit forms.
Detect form type message
You can check if a message contains forms.
Saving user input
You can update the form field's temporary answer as the user types.
Validating user input
You can validate the form field's input and update the UI accordingly.
Submitting a form
You can submit form data to the server using the submitForm()
function. The Chat SDK sends all non-empty formField.temporaryAnswer
data to the server. It involves handling possible errors, such as invalid form fields, and updating the message UI upon successful submission.
Enable form type message in UIKit
You can enable the form type message feature in UIKit by following the code below.