Power BI¶
BotCity Insights offers the possibility to integrate Orchestrator data with the Power BI platform using API resources.
This way, you can continue using the features you are already familiar with along with the data reported to BotCity Insights.
Info
The intention of this guide is to demonstrate only a few simple examples that can be used in the context of Power BI.
For a more complete reference of the BotCity Insights API, visit this link.
Authentication¶
The first step to use the BotCity Insights API is authentication. The API uses an authentication token that is sent in the header of all requests.
To obtain the access token using Power BI resources, follow the steps below:
- Access Power BI Desktop and create a new report.
- In the
Get Datamenu, select theBlank Queryoption. - Open the newly created query with the
Advanced Editorso that you can enter the code using Power Query M.
The code that will be used in this step is very simple, a POST request to the API login route passing the login and key information in the request body.
Tip
The login and key information can be obtained on the Developer Environment page of your workspace in the Orchestrator.
() =>
let
// Login route
url = "https://developers.botcity.dev/api/v2/workspace/login",
headers = [#"Content-Type" = "application/json"],
// Passing the workspace information in the body of the request (Dev. Environment)
postdata = Json.FromValue(
[
login = "<WORKSPACE_LOGIN>",
key = "<WORKSPACE_KEY>"
]
),
// Getting the response
response = Web.Contents(url, [Headers = headers, Content = postdata]),
Data = Json.Document(response),
access_token = Data[accessToken]
in
// Returning the obtained access token
access_token
When you execute this query, you will notice that an API access token will be returned.
Done! With the function that returns the API access token, you can now use it as a parameter in the other requests to consume the report data.
Consuming report data¶
The following endpoints can be used to consume BotCity Insights report data:
| Type | Route | Description |
|---|---|---|
GET |
/api/v1/insights/tasks |
Lists the data related to executed tasks |
GET |
/api/v1/insights/runners |
Lists the data related to workspace runners |
GET |
/api/v1/insights/automation |
Lists the data related to automations |
Still in the created report, follow the steps below to consume the data using the BotCity Insights API:
-
In the
New Sourcemenu, select the option to create a new query using theWebsource this time. -
In the opened window, check the
Advancedoption and enter the base URL of the BotCity Insights API.
-
In the second field referring to the URL parts, enter the route you want to use to consume the data.
-
As mentioned earlier, all BotCity Insights API requests require a
tokenand anorganizationto be sent in the requestheader. -
In the
HTTP request header parametersfield, enter thetokenobtained in the authentication step and theorganizationrelated to your workspace.
Tip
The value of the organization parameter will be the same as the login field, which can be obtained on the Developer Environment page of your workspace in the Orchestrator.
When the request is executed, the API response will be displayed in the data source configuration window.
With the API response, you can now perform the necessary treatments to display the data as desired.
Using the API in an advanced way¶
Making Power BI requests dynamic¶
When creating the query in the above format, Power BI will automatically generate code using Power Query M, containing the information that was passed.
In the example above, the access token parameter was passed manually, but we could make a small change to make the authentication step more dynamic.
Editing the query with the Advanced Editor and including the change to use the function created to obtain the token, we would have something like this:
Tip
The function responsible for obtaining the access token created in the authentication step can be passed as a parameter in future requests.
With this treatment, the token will be generated dynamically whenever the query is updated.




