Flow Designs: Capture user input
Captured user data can be used to:
- Create a ticket in your CRM tool
- Make API calls
- Integrate with external services
Entities vs. Any Text
The two most common ways to capture user input are by using Entities and Any Text.
Entities
Entities are variables you give your bot to categorize and interpret user input. Entities are great for picking variables out of sentences such as arrival city or destination city.
Any Text
The Any Text Trigger is used to capture any text that the user types. This option does not require any AI and therefore doesn't need training examples.
You can combine Any Text with Actions to verify user input.
Use extracted data or input
Your parameter has now been created and contains a value. You can use this data to send an e-mail or to make API calls for several solutions. Have a look at our Code-based Action Best Practices
Send email with extracted data
To send an email with the extracted data you can use an action. The following example incorporates three parameters:
- name
- message
Make sure to extract them before sending the email. Otherwise you'll be missing some valuable content.
async payload => {
var name = "-"
var email = "-"
var message = "-"
// Check if the param "name" exists
if(Array.isArray(payload.params.name)) {
var name = payload.params.name[0].value
}
if(Array.isArray(payload.params.email)) {
var email = payload.params.email[0].value
}
if(Array.isArray(payload.params.message)) {
var message = payload.params.message[0].value
}
toolbelt.email({
to: '[email protected]', // \<-- Vul hier een email adres in
subject: 'New message via chatbot',
message: `name: ${name}, <br/>
email: ${email}, <br/>
message: ${message}`
})
}
Updated about 1 year ago