Convert a Composer bot
Create a new flow
We will now proceed to create a flow (dialog) to hold the logic of the get_weather dialog in the Composer bot.
- Select the Solution root folder and click on Flow in the ribbon bar.
- Give your flow a name like
Get weather
. - Add the description,
Get the current weather conditions.
. - Click on the back arrow at the top of the menu to go to the main flow view.
Populate trigger
Now it is time to populate our trigger.
- Select the trigger and name it
Get weather
. - In the Match section in the configuration panel, click on Add followed by TLML Syntax.
- In the TLML Syntax field, enter
weather
.
Add outputs
Next, we need the prompt a response that asks for the user's postal code.
- Click on the output node and name it
Ask for postal code
. - Paste in the output
Let's check the weather. What's your postal code?
.
Add flow variables
Variables are important when building bots. Not least, your bot's memory will rely on what is stored in variables. In order to store user's postal code, we will need to create a new variable. We will also need some variables to store the information we will shortly be getting from the weather API.
- Click on the FLOW button to reach the flow backstage panel.
- Select Variables in the menu.
- Click on Add.
We will now proceed with creating a variable that takes the postal code from the user input and is later used together with the HTTP request. As an extra addition, we add a initial value for our variable.
- Give the variable the name
postalCode
and the initial value90210
.
Next in line is to create some more variables that will be taken from the Weather API we have called and used inside our flow.
- Go ahead and add the following variables too, as we will need them once we call the Weather API:
Variable name | Value |
---|---|
celsius | 0 |
city | '' |
country | '' |
fahrenheit | 0 |
icon | '' |
responseCode | 0 |
weather | '' |
- Click on the back arrow at the top of the menu to return to the main flow view.
- Hit 'Save' and close the flow.