Add words to a list

The case will be useful for a user in making his own list of no repeating words in the bot and, if necessary, display it in the messenger.

It can be used in entertainment bots for word games or in other cases where it may be relevant.

On Start screen, create an empty list using Assign a Variable. Let's call it Arr.

Add Rewind.

Create the "Menu" screen, on the Start screen we will make a transition from Rewind to it. In "Menu" add a button with a transition to the next screen, where the user will send a word to the bot.

On the "Adding a word" screen, we will ask the user what word he wants to add and write this word to the word variable.

Below we will add a variable entry, where we will write to the arrCheck variable the following:

{{inArray Arr word}}

This helper will check whether the word that the user wrote was in the list before.

Below we will add Fork with checking the arrCheck variable, to do it, we will add arrCheck to the variable name, from where the Fork takes the value.

Add one goal.

The data type is - false. This means that the goal of the fork will work only when the word does not match any word sent earlier by this user.

Add a transition from Goal 1 to the screen "This word doesn’t exist in the array. Add it."

Also, in the fork settings, the perform the next component if the screen is not set checkbox should be active.

If the word doesn’t exist in the array yet, Goal 1 of Fork will work and the word will be added.

If there was such a word, the goal will not work and the user will go down the same screen to Buttons with hints and Fork.

There will be a notification on the buttons that this word exists in the array and a suggestion to add another word. By clicking the "Yes" button, the user will get to the beginning of the same "Add a word" screen, since this screen is set in the default transition in Fork.

The user will be able to send another word to the bot.

Let's design the screen "This word doesn’t exist in the array. Add it."

The user will get to this screen if the word he entered was not in the list before.

Add a message where the bot will write what word it will add to the array. We will also add Write Variable.

The variable name is Arr again, in the value we output {{world}} - the word that the user sent to the bot before.

In the settings of Write Variable, we note - List Management - Add to the end.

After that, add buttons that will transfer to the "Add a word" screen, where you can add a word again. By clicking on the second button, you can view the list of added words.

If everything is done correctly, all the screens together will look something like this:

To the beginning ↑