# Getting Business Insights from Your Agent

AI operations team are often interested in understanding and measuring the technical performance and business impact of production workflows. Technical performance analytics, such as uptime and latency, is available in the [Analytics view](/agentic-adoption-and-security/observability/analytics.md) of each workflow. This article explores how to turn raw running logs into business insights, such as user interaction trends and process automation performance.

### AI-Powered Flow Report

An **AI-Powered Report** is available for every workflow in StackAI and can be generated on-demand. This report contains a summary of interaction patterns, thematic analysis of inputs and outputs, and suggest workflow enhancements based on usage analysis.&#x20;

<div align="left"><figure><img src="/files/BJEcJZfHDi3yWRM9KXDS" alt=""><figcaption></figcaption></figure></div>

### Customized Flow Report

Beyond the AI-Powered Report, operators can create analytics workflow within StackAI. The rest of this article will provide example projects you can [import into your organization](/interface-and-deployment/end-user-interfaces/exporting-and-importing-projects.md).&#x20;

#### Simple Report

Below is a simple form of a customized report.

{% file src="/files/asqdtUg18xMCPI1IVCp3" %}

<figure><img src="/files/r7EOdRUL5NoqL3UUiMot" alt=""><figcaption><p>Example workflow: simple report</p></figcaption></figure>

{% stepper %}
{% step %}
**Set up HTTP request**

You can use the Analytics APIs to download historical data. See [here](broken://pages/fa4d62b48a82b3aaa421c682970681c5183d2a65) for the full API documentation.&#x20;

To set up the HTTP request, you will need the project ID of the production workflow and an API key.&#x20;

<div align="left"><figure><img src="/files/HiEbHbz3BjsB1rae9bFQ" alt="" width="375"><figcaption></figcaption></figure></div>

The project ID can be found in the url of the project: `https://www.stack-ai.com/project/`[**`698xxxd95`**](#user-content-fn-1)[^1]`/workflow`. The API keys are managed by the organization Admins and can be found under [Settings > API Key > Organization Private Key](https://www.stack-ai.com/settings/api-keys).
{% endstep %}

{% step %}
**Review Python node**

The Python node in the template is already set up to transform the historical data into LLM-ready format. You can modify the code further to adapt to your needs.
{% endstep %}

{% step %}
**Set up instructions for analysis**

The example project includes sample prompts. You can update prompts in the AI agent with instructions on the usage analysis and the output format.&#x20;
{% endstep %}
{% endstepper %}

#### Scheduled Report

You can run the report periodically with a trigger.&#x20;

{% file src="/files/xMKmE9D0nJlIOwl490GS" %}

<figure><img src="/files/twvR2ECYLhAoPO46ZVdd" alt=""><figcaption><p>Example workflow: scheduled report</p></figcaption></figure>

{% stepper %}
{% step %}
**Set report frequency**

<div align="left"><figure><img src="/files/8wKQYdbv5QEz4M3oehKO" alt="" width="375"><figcaption></figcaption></figure></div>

You can configure the frequency, time, and timezone of the trigger.
{% endstep %}

{% step %}
**Set report interval**

<div align="left"><figure><img src="/files/MpMCXSdkMbYt3eOHo2Rk" alt="" width="375"><figcaption></figcaption></figure></div>

The time tool fetches the date when the report is run.&#x20;

The python node outputs the start date of the report. For example, if the report runs every 14 days, you can change the number of days in the code to 13, as the analysis start date is 13 days before today. &#x20;
{% endstep %}

{% step %}
**Update the rest of the workflow**

Follow the guide in Simple Report to finish setting up the HTTP request and analysis instructions.
{% endstep %}
{% endstepper %}

#### Scheduled Report, Delivered

You can further enhance the periodic reporting by sending an automated communication. The example project includes an Outlook tool, but you can change it to other email providers or applications.

{% file src="/files/VdXbqMqnLpSCSvfq4tnJ" %}

<figure><img src="/files/yWS5YpSx4wr8wBYnG1AM" alt=""><figcaption><p>Example workflow: scheduled report with email</p></figcaption></figure>

Using Outlook as an example, you can create an OAuth2 connection to your email address and configure email recipients, subject, body, and attachments.&#x20;

You can set up these values manually, or let AI infer from your prompt. See [Prompt Optimization with Tools](/workflow-builder/core-nodes/ai-agent-node/tools.md#prompt-optimization-with-tools) for more details.

<figure><img src="/files/jsKi9fg5GSfOvTaJmCcV" alt=""><figcaption></figcaption></figure>

[^1]: This is the project ID


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stackai.com/guides-and-tips/stackai-hacks/getting-business-insights-from-your-agent.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
