Aimylogic is a visual tool for building of conversational UI and skills for voice assistants and messengers. You can learn more at Aimylogic Basics. In this simple tutorial we show you how it's easy to use Aimylogic for conversational scenarios development.

Please note that you can try this tutorial in action without building it. Just click on "Guess number" template on the main page of Aimylogic to open and play with a complete scenario.



How to create a bot

Aimylogic enables you to create bots - a conversational agents that understand users' queries and performs some actions. Here in this tutorial we create a gaming bot that plays with user in well knows "Guess my number game".

The bot makes a number in a range between 1 and 100, and user tries to guess it in the conversation.

Create a new bot

Open app.aimylogic.com in your browser, create an account and sing in. Click on Create a bot button and type the name of new bot. Select English language and click Continue button.

Create a new bot

Create scenario for the bot

Each bot contains at least one scenario - a logic of the bot's conversation with the user. Once you've created a new bot, a visual editor of main scenario appears. Here you can see a menu of blocks that can be used in your bot's scenario.

Blocks menu in Aimylogic

This menu is used to add new blocks to the screens of scenario. Each block performs some actions during the conversation with the user.

The first screen

Click on the Text block. It will output the greeting and ask the user if they are ready to play game.

First Text block

Fill a text like on a screenshot above and click on Save to add this block to the first screen of your scenario.

You can also customise a speech of your bot, please learn more in Text article

Intents

Once the bot has generates a greeting message to the user, it should wait for the user's response. The user can say Yes if they would like to start a game, or anything else. The bot should understand this intent and react accordingly.

Aimylogic has an Intents block to train your bot to understand user's replies. Click on the +Block button on the first screen and pick Intents from the Block menu.

Intents block

Here you can provide examples of phrases for each intent that can be recognisable by your bot, Add a single intent with a single example phrase - yes. And click Save.

Aimylogic trains your bot with your examples phrases

Make a random number

Great! Now we have created a very first screen of our scenario. It should look like this one

The first screen

Once the user says "Yes" the bot should make a random number and invite user to guess it. Click on yes intent in the Intents block - a new screen will be created automatically and Block menu will appear.

On this screen our bot should make a number in a range between 1 and 100. We'll use a special API of an external web service that can generate true random number. There is a HTTP Request block that enables a bot to invoke an external web services and fetch the data.

Clock on HTTP Request in the Blocks menu and fill URL field with https://www.random.org/integers/?num=1&min=1&max=100&col=1&base=10&format=plain&rnd=new. This web service will generate a true random number and return it in the response.

Our bot should save this value in some variable and then use it on the next screen. To save a response to the variable, please click on Variable name and value and add variable with name num and value parseInt($httpResponse).

HTTP Request settings

Click on Save button, Now our scenario should look like



Once the user says yes - the bot jumps to the second screen where it invokes an external HTTP API and stores a random number between 1 and 100 in the variable named num.

Wait for a number

Okay! The user says Yes and the bot makes a number. Now the bot should invite the user to guess this number and wait for the response.

Click on Success in the created HTTP Request block - a new screen appears with opened Blocks menu. Add a text blocks again with some text that invites the user to guess a number. Then add Transition block to transit the bot to the next screen. Click on it to create a new screen, Here add Intent block with the next data

Wait for a number from the user

Here you can see two intents. The first reacts once the user replies with some number. The second reacts if the user would like to stop a game with phrases like "Stop", "Stop a game" and etc.

User $NUMBER system entity to train a bot to extract the number from the user's reply

Now your scenario should look like (you can drag and drop screens to rearrange them)



Check a number

Once the user replies with some number, a bot should compare it with those it has in num variable. If the user replied with a number less or greater than a bot's number, a bot should say about this and wait for a next number again.

Clock on a $NUMBER intent in the created Intents block, and add Conditions block on the next screen. This block can branch scenario depending on the Javascript conditions results.

Conditions block

Add two conditions, The first checks if the bot's number is greater then the user's one, The second - if it's less. Click on Save. Aimylogic also automatically adds else condition - it signals that the user's number equals to the bot's one (yay, the user guessed a number!).

Click on the first condition and add a screen with a message that informs a user about a mistake and invites them to try again. Then add a Transition block to this screen that transits the bot back to the screen where it waits for the user's number. Make the same steps for the second condition. You should have something like this



Else branch

If the user says the number that equals to the bot's, no one of two condition matches and the default else condition will be invoked. Click on it to create a new screen and add some text that congratulates a user.

Congratulations!

You can insert an actual num variable value to the text. Just place a $num placeholder to the text like "Yes! It was $num! Congratulations!" Aimylogic will replace $num placeholder with an actual value automatically before the rendering of this text bubble to the user.

End of scenario

We'll connect this bot to the voice assistant like Alexa in the next chapter, so we have to inform Alexa that the bot was finished it's work and Alexa should close the microphone and exit from a skill. Aimylogic provides an End of Scenario block for this purpose. Just add this block to the screen with congratulations.

Test it

And that is all! We created a first version of gaming bot, and now we can test it in the test widget. Click on the Test button on the top right corner of the editor. A test widget appears, Here you can send some test queries according your scenario and see how it actually works.

Test widget

Create a skill for Alexa

Alexa is a well known voice assistant that speaks with user of Amazon Echo devices. Aimylogic enables you to easily create skills for Alexa just connecting a bot to the Amazon Alexa channel.

Click on the Channels item in the left menu of editor. Then click on Alexa button to add a new channel to your bot. A channel settings window appears

Alexa channel settings

You can leave everything as is for now. Clock on Connect button. Aimylogic will redirect you to the Amazon Sign in page where you have to grant Aimylogic to manage your skills in your Amazon Developer account. Once you've done this, Aimylogic creates a channel and registers and builds a skill automatically.

Note that a skill building may take up to 5 minutes. Please be patient and wait a bit.

Once a skill is successfully built, Aimylogic informs you with a popup message in the bottom left corner. Now you can invoke your skill on Echo device or click on the Open Test Console button to open an Amazon's development console.

Amazon Alexa test console

You can say or type "Play guess number game" to start your skill and test it.

You can also use an existing Echo device to test a skill on a real device

Where to go next

In this quick start we've made a simple game that interacts with the user on a natural language, invokes an external service through an HTTP request and branches scenario depending on the user's replies. Also we learned how to connect this bot to Amazon Alexa and test it on a real Echo device.

To go next with Aimylogic we recommend to learn more about Aimylogic Basics and then try our Tutorials.
Was this article helpful?
Thank you!