Welcome to the part two of the API Connector tutorial series. In the previous video, we learned how to add the API key to the account through the admin section of the account. In this tutorial we are going to create an automation where we utilise the API key to extract the weather data for any selected city. In the Part three of these series, we will be elaborating on the function of the API Connectors in more technical details. So, make sure to watch the API Connector part three – technical explanation to learn more and perhaps find the answers to the questions you may have have.
Let’s get started!
1. Click Add New and give your bot a name
2. From the Inputs menu, add a Text node
- Update the name of the node and give it a description. This description will be what the user on the front end is going to see as the instruction
- Make sure to Toggle Required before moving on to the next step
3. From the Workflow menu, select API Connector
- Select the relevant Provider (AccuWeather) from the drop-down menu
- Select “Weather – Get City ID” from the Connector drop-down. AccuWeather’s API uses unique “city IDs” to identify specific locations. So, when using an API, you must provide the city ID instead of the city name when querying the API for weather data
- Select the method Get
- Click on Configure connector
- Set the Value as Variable and select your variable (Text – City Name) from the drop-down menu
- Save your settings and set the Trigger as With dedicated button
- Name the Button “Get Information” or anything else that makes sense.
4. From the workflow menu, select Variable Mapper and select API 1 as its source node
- Select JSON as the Source Type and Click on Map Variable
- Type in the JSON key, identify it with the relevant name, and save
5. Add a logical condition node
- Edit the logic by selecting: “Mapper 1 City ID” and condition as: “Is not empty”. The logical condition acts as a gateway, allowing the API node and Variable Mapper node to get the information for processing in the next step and ensure that this information is a valid input for the next nodes
6. Add an API connector
- Filter the relevant provider and select “Weather current data” as your connector
- Method remains as Get
- Configure connector by selecting “mapper1 City ID” as your variable and set the trigger to When loading this node
7. Add a Variable mapper
- Select the source node as API 2, source type as JSON, and map the variables with the right JSON Key and Variable name
- If you would like to have the temperature solely as a number, you can complete your bot by adding a text field where the result can be shown
8. Add another Variable Mapper
- Select API 2 as the source node and source type as text
9. Add a logical condition node
- Edit the logic by selecting Mapper 3 as the variable and Is not empty as the condition
10. Add an AI Output Node
- Create the AI setting and give your Default values suitable names
- Click on Edit Prompt and type your desired instructions in the System prompt, inserting Mapper 3 in your Dynamic Prompt
- Automate the node by selecting When loading this node as the trigger
11. Add a Text field
- Click Create and type “Temperature and Summary of the weather conditions”
- Click on Add Field Input
- Add “Mapper 2 Temperature” in front of “Temperature”
- Add “AI output 1” in front of “Summary of the weather conditions”
12. Click on Preview and enter a City name
- Press “Get information”
- The temperature and the summary of the weather conditions will be generated in a few seconds