Working with chatbots it’s sometimes useful to parse and store the user response somewhere.

In RedBot there’s the chat context, it’s a volatile memory space where it’s possible to store variables related to the current chat user, for example consider this flow in which we ask the user to type in his email

parse-email

The first Message node just sends out the question to the user “What is your email?” (always use a conversational tone with a chatbot and not cold robotic sentences like “Type your email”).

Note that the Telegram Sender node has the track option enabled, that means that the chat flows will re-start from here: any answer from the chat user will be redirected to the output pin following the rest of the flow.

The Parse node analyze the incoming message and cab be configure to search for a pattern, it could be email, image, location, etc.
In that case it searches for a valid email: if the content of the incoming messages matches the pattern, the value is stored in the chat context and the output is redirected to the first output, otherwise the second output.

If the user’s input doesn’t match a valid email, a warning message is sent to the user and the flow restart from the node asking for the email.

If a valid email is found, it’s stored in the chat context (the name of the variable can be configured in the Parse node panel) and it’s available in the rest of the flow.

For example we can use it in the final Message node with a handlebars-like syntax with the text: “Thanks, from now on I’ll use {{myemail}} as your email”.

Or we can use it in a Function node:

To setup a Telegram bot, follow the tutorial.