Build a Bot Insight dashboard bot
- Updated: 2020/11/17
Build a Bot Insight dashboard bot
In this example, you build a bot that retrieves data from a website to create visualizations in Bot Insight.
Procedure
-
Create a new bot:
- On the left panel, click Automation.
- Click + Create > Task Bot.
- In the Create Task Bot window, enter the bot name.
-
Accept the default folder location: \Bots\
To change the default bot storage location, click Choose and follow the prompts.
- Click Create and edit.
-
Open a browser window to the web page from which you want to extract the
table.
- Double-click or drag the Browser > Launch website action.
- In the URL field, enter https://www.statista.com/statistics/183483/ranking-of-languages-spoken-at-home-in-the-us-in-2008/.
-
Select the Internet Explorer browser.
Note: Use Microsoft Internet Explorer because it reliably launches the website in a new window, even if another window is already open. Other browsers might launch the website in a new tab if there is an open window.
- Click Save.
-
Click Run.
The bot opens the window.
-
Select the table for extraction.
- Double-click or drag the Recorder > Capture action.
-
Click the Window tab and select the
Languages spoken in the United States 2018 |
Statista window from the drop-down list.
If the window title does not appear in the list, click Refresh.
-
Click Capture object.
The Languages spoken in the United States 2018 | Statista window is activated.
- Hover over the table until an orange box that surrounds the entire table appears.
- Click the table.
- Return to the Control Room.
-
In the Object properties table, verify the Control Type is TABLE.
If it is not, click Recapture object.
- From the Action drop-down list, select Get table.
-
In the Assign output to variable field, create
the
tLanguages
table variable.
-
Specify the file in which to save the data.
- Double-click or drag the Data Table > Write to file action.
- From the Data table name list, select tLanguages.
-
Provide a file path to create a CSV file.
For example, C:\Users\<username>\Desktop\LanguagesTable.csv.
- Select the Create folders/files if it doesn't exist option.
- Select to overwrite the existing file.
-
Specify the file that holds the extracted data.
- Double-click or drag the CSV/TXT > Open action.
- Provide the file path to the file specified in step 4.
- Select the Contains header option to exclude the first row.
-
Iterate though each row of the file.
- Double-click or drag the Loop action.
- Select the For each row in CSV/TXT iterator.
-
In the Assign the current row to this variable
field, create the variable
rCurrentRow
.
-
Specify the data to populate the Bot Insight dashboard.
- Double-click or drag the Analyze > Open action.
- Double-click or drag the String > Assign action.
-
Enter $rCurrentRow[0]$ as the source
string.
Press F2 to open the variables menu.
-
In the Select destination string variable field,
create the variable
sLanguage
. -
Double-click or drag the String > Replace
action.
The extracted data uses commas to separate digits. You must remove the commas before you can convert the string to a number data type to use in Bot Insight.
-
Enter $rCurrentRow[1]$ as the source
string.
Press F2 to open the variables menu.
- Enter , in the Find string field.
- Select the Not a regular expression option.
- In the Replace with field, enter $sNull$.
-
In the Assign the output row to variable field,
create the variable
sPopulation
. - Double-click or drag the String > To number action.
-
Enter the
$sPopulation$
variable. -
In the Assign the output row to variable field,
create the variable
nPopulation
. - Double-click or drag the Analyze > Close action.
-
Select the following variables:
- sLanguage
- nPopulation
- Click Save and then Run.
-
Click Analyze.
The Bot Insight window appears.