Convert a Composer bot
Finish off flow
Now we can finish the flow by calling the new integration and adding more functionality.
Extract the user's postal code
We need to make sure we are actually extracting and storing the postal code given by the user.
- Go back into the flow you created earlier.
- Under the output node, click on the Plus icon, followed by Continue with and Transaction.
- The transition between the output node and the new integration node should now be selected; give it a name such as
Extract postal code
. - In the After Match section, add an After Match for Entity.
- Paste in
NUMBER
in the Entity field. - Click on Add Mapping below the Entity field. Using the drop-down menus below, select the source
nNumber
and the targetpostalCode
. - In the Match section, add a Match for Entity.
- Paste in the Entity
NUMBER
.
Add the integration node
Now we can set up the call to the integration in the integration node we just added.
- Underneath the Extract postal code transition, click on the Plus icon. Select Continue with, followed by Integration. Choose your new Weather integration.
- Give it a name like
Get weather
. - Now you will need to specify which variables should be used for the information you send to or receive from the integration. First select the drop-down menu in the Send section and select the variable
postalCode
. - Select the appropriate variables for all of the drop-down menus in the Receive section. These are the response code, celsius, city, country, fahrenheit, icon, and weather variables that you created earlier.
Summarize weather
Let's finish off the structure of the flow to send the weather results to the user.
- Click on the Plus icon underneath the integration node.
- Click on Match, followed by Script.
- Paste in the evaluation script
responseCode == 200
. - Give the transition a name like
Success
. - Select the output below the Success transition and give it the name
Summarize weather
. - In the output node, paste the answer
The weather is ${fahrenheit}°F or ${celsius}°C and ${weather}.
.
Add a fallback transition
Finally, let's add a fallback transition in case the bot does not manage to successfully retrieve the weather based on the user's input.
- Select the integration node and click on Output in the ribbon bar.
- Give the output node the name
Something went wrong
. Reuse the same text for the output answer. - Click on the transition above the output node and give it a name like
Failed
. - Hit 'Save' and close the flow.
Was this page helpful?