Collect input

A Collect input block can be used to get information from the user. When the user gives information, the bot will first check if the info corresponds to an already known variable.

A Collect input gets info from the user, checks it, and saves it as a variable.

A Collect input will typically be configured as of:

Input types

The Collect input blocks have 3 types of input recognition:

  • General input types to check if the input follows a desired format.

  • System input types to check if the input follows a certain Chatlayer built-in entity.

  • Entity input types to check the user input with a bot entity.

Chatlayer extracts data from user inputs. For instance, if an input plugin has a type of date and the input is 'I need to be in Paris in two days,' the parser will identify 'in two days' as the date. It converts this into the DD-MM-YYYY format and stores the result in the user session.

General input type

The General input type checks if the input follows a desired format:

Any

The Any input type will accept all string values as an input.

It is important to know that intents and entities are processed before parsers. This can be useful for automatically extracting certain pieces of a sentence as an answer to a question. We've provided a great example of this in our tutorial.

Date

The Date input parser type will parse the response as a date. Sentences like 'next week Monday' are automatically converted to a DD-MM-YYYY date object. Supported formats (also in other supported NLP languages) are:

  • 22-04-2018

  • 22-04

  • 22 apr

  • 22 april 18

  • twenty two April 2018

  • yesterday

  • today

  • now

  • last night

  • tomorrow, tmr

  • in two weeks

  • in 3 days

  • next Monday

  • next week Friday

  • last/past Monday

  • last/past week

  • within/in 5/five days

  • Friday/Fri

Image

The Image format type allows you to check if a user has uploaded an image or other file (such as pdf).

The image will be saved as an array. If you chose {img} as variable, this means that you should use {img[0]} to retrieve the URL for the first saved image.

For the chat widget (web channel), we recommend using the file upload step.

To save a user's attachment at any point in the flow, use the defaultOnFileUpload variable. This variable will store the URL of the attachment uploaded by the user, regardless of where they are in the conversation.

Location

The Location parser sendsthe user's input to a Google Geocoding API service. When a correct address or location is recognized, the Chatlayer platform will automatically create an object that contains all relevant geo-data.

Look at the block above. When the user answers the question "Where do you work?" with a valid location, this information will be stored as a userLocationInformed variable (you can rename this variable if needed).

Below is an example that shows how the userLocationInformed variable would be stored when the user responds with 'Chatlayer.ai':

{
    fullAddress: "Oudeleeuwenrui 39, 2000 Antwerpen, Belgium",
    latitude: 51.227317,
    longitude: 4.409155999999999,
    streetNumber: "39",
    streetName: "Oudeleeuwenrui",
    city: "Antwerpen",
    country: "Belgium",
    zipcode: "2000",
}

To show the address as a full address (street, street number, zip code and city) you need to add some extra information to the variable: .fullAddress

So in the example above, the bot can display the entire location by using the following variable:{userLocationInformed.fullAddress}

A bot message containing the following info:

Thank you, shall I send your package to {userLocationInformed.fullAddress}?

Will display the following message to the user:

Thank you, shall I send your package to Oudeleeuwenrui 39, 2000 Antwerpen, Belgium?

Language

This input type will parse and validate NLP supported languages.

  • English: (en-us): 'engels', 'English', 'en', 'anglais'

  • Dutch (nl-nl): 'nederlands', 'Dutch', 'ned', 'nl', 'vlaams', 'hollands', 'be', 'ned', 'néerlandais', 'belgisch'

  • French (fr-fr): 'French', 'français', 'frans', 'fr', 'francais'

  • Chinese (zh-cn): 'Chinese', 'cn', 'zh', 'chinees'

  • Spanish (es-es): 'Spanish', 'español', 'es', 'spaans'

  • Italian (it-it): 'Italian', 'italiaans', 'italiano', 'it

  • German (de-de): 'German', 'duits', 'de', 'deutsch

  • Japanese (ja-jp): 'Japanese', 'japans', 'jp', '日本の

  • Brazil Portugese (pt-br): 'Brazil Portugese', 'Portugese', 'portugees', 'braziliaans portugees', 'português'

voiceMessage

Use the voiceMessage input type to save voice channel messages as text. Configure the maximum duration and completion time for these messages.

Hours

This input type will parse and validate timestamps.

System entities input type

The Collect input parser can check if the given input is consistent with the format for one of the following system entities. Whenever a system entity is chosen in the 'Check if response matches' dropdown, you can give the variable a name that works for you.

To learn more about the input and output of the system entities, check out the examples in your own bot via NLP > Entities > System Entities.

@sys.email

@sys.email validates if the user input has an email format. If the input is not an email, the bot shows the 'If user response is not valid..' messages at the bottom of the Collect input.

@sys.phone_number

@sys.phone_number accepts numbers with more than 6 and fewer than 17 numbers in them.

@sys.number

Any numbers entered are recognized as @sys.number. Since multiple numbers might be requested in different Collect input blocks, assign each a unique name. When selecting @sys.number in Check if response matches, you'll have the option to name the variable uniquely.

@sys.url

@sys.url checks if the given input is a URL. Accepted formats can be with www (www.chatlayer.ai) or without (chatlayer.ai). Just the domain 'chatlayer' will not be accepted.

Entity input type

After you created an entity, you can check that the user input matches it.

Lear more about which entity type suits your use case.

Match entities

Match entities can be recognized in Collect inputs.

Let's say, you have created this awesome bot for your fries shop:

To use the 'food' entity with values 'burger' and 'fries' in a Collect input block, follow these steps:

  1. Create the entity 'food' with values 'burger' and 'fries'.

  2. In the Collect input block, configure it to check if the response matches the 'food' entity.

Whenever the user provides input, the platform checks if it matches an accepted value for that entity. If the input isn't valid (e.g., not 'fries' or 'burger'), the bot will trigger the 'Invalid user response' section.

Contextual entities

For contextual entities, you can also check if there is a match between the input given by the user and the contextual entity values saved in your bot.

This will check if the answer is listed in the values of the entity.

2 important things to note for contextual entities in Collect input blocks:

  • If fuzzy matching is enabled, answers such as 'Brussel' or 'Antwerpp' will also pass in the Collect input as a correct answer.

  • In this input block, if NLP is enabled, a phrase like "To Antwerp please" could trigger the intent and save the variable 'Antwerp'. If the sentence isn't recognized beyond the NLP threshold, the bot will go into the 'When user response is not valid' section. Test this with your NLP model and create appropriate 'When user response is not valid' messages. Note that answers like "To Antwerp please" could work depending on your NLP model's accuracy.

Composite entities

When choosing a composite entity, the entity name is also prefilled for you:

Here, we have an @order composite entity, which consists of @sys.number and @food. So user input that will be accepted is '2 fries', 'three burgers' etc.

This will be saved under the variables 'order.sys.number' and 'order.food', as can be seen in the debugger:

The Collect input input types will enhance your flow. If you have any questions do not hesitate to contact Support.

Check if a response matches

A Collect input block checks whether the user response matches an already-known variable.

2 things can happen at a Collect input point of the conversation:

  • The variable does not have a value yet, so bot will ask the question written in the Collect input block. Here, either:

  • The variable has a value already, the bot will automatically skip the Collect input block.

On match

If the response is matched at the time where the Collect input gets triggered, it will be saved correctly under the specified variable name in the debugger.

If the Collect input block is skipped, that is because the variable is already known. Variables can be known already for various reasons:

  • The user has answered this question before.

  • A previous entity was detected with the same variable name.

  • The user is authenticated and the variable was automatically set.

On no match

When the user provides an invalid response (e.g., the bot asks for an email address and the user replies with 'chicken'), the bot should inform the user that their answer was invalid.

To achieve this, you can create a message for when Collect input fails once, and another for when it fails three times. Additionally, enable no-response detection to manage cases where users provide no input. This ensures smoother bot interactions.

First two times

For example: the first time an input fails, the error message could simply be "Sorry, I didn't get that. Can you try again?" or "Sorry, that doesn't seem to be a valid date. Can you try the DD-MM-YYYY format?".

After two times

When the user fails to give valid input 3 times in a row, you have the flexibility to redirect them to a block. For instance, you can guide customers with an error message like "Sorry, I can't seem to understand. Please contact our support team at [tel number]". Alternatively, the bot can also offer to transfer the user to a live agent for further assistance.

On no response

You can configure the bot to detect when a user remains silent for a specified period. It triggers a specific block when no response is received within the set timeframe or by a predetermined time.

You can set how long it takes for the new block to trigger in the duration field (in minutes or at a specific time). The duration of silence can be from 1 minute up to 1440 minutes (24 hours).

Configuration

The bottom of your Collect input block can be configured so that you're sure to detect the answer that you're looking for.

Disable NLP

Users are able to leave the Collect input if an intent is recognized. For bots with a very small NLP model, this might trigger a false positive. The 'disable NLP' checkbox allows you to disable the NLP model while in the Collect input, which makes sure that whatever the user says gets saved as input.

For date variable: Always past - always future

When you decide to check a date variable, Chatlayer parses the user expression to match a default date format. If the date you ask should always be in the present or future, you can use these options. A user saying “Thursday” for example will be either mapped to last or next Thursday.

Last updated