Back to Blog

How to capture user input

Flow.ai allows you to capture and use the input of the user. Captured data can be used to:

Entities vs. Any Text

The two most common ways to capture user input are by using Entities and by using 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.

Capture and use input

Any Text

The Any Text Trigger can be 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 Check user input.

Capture 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 Actions Best Practices.

Send e-mail with extracted date

To send an e-mail with the extracted data you can use an action. In the example below the following three parameters are incorporated:

Make sure to extract them before sending the e-mail. 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}`
  })
}
Get StartedContact us