Announcing Native Azure Functions Support in Azure Container Apps
May 16, 2025What Is Platform Engineering?
May 16, 2025đ Introduction
Manually compiling and distributing daily performance reports can be time-consuming. This post demonstrates how to automate this process using Azure Logic Apps (Standard), Azure OpenAI, and Prompt Templates to generate insightful daily summaries and deliver them directly to Microsoft Teams.
Here’s a visual representation of the automated workflow:
đ˘ Scenario
Imagine needing to provide a daily summary of branch performance for a multi-location restaurant business. Instead of manually gathering data, calculating rankings, and writing a summary, a Logic App can:
- Run automatically each day.
- Read the latest sales and performance data from Azure Blob Storage.
- Use Azure OpenAI with a carefully crafted prompt template to analyze the data.
- Generate a formatted, engaging leaderboard summary.
- Post the summary directly to a specified user or channel in Microsoft Teams.
đ§ Demystifying Prompt Templates
Think of Prompt Templates as smart blueprints for your AI conversations. They are pre-defined text structures using Jinja2 syntax, allowing you to insert dynamic data (like daily sales figures) exactly where needed when the Logic App runs.
For our Logic App, this translates to:
- Crafting a base prompt with placeholders, such as {{ branch.TotalSalesEuro}} for sales figures.
- Letting the Logic App automatically fill these placeholders using data retrieved earlier (e.g., from the blob storage file).
- Ensuring the AI receives well-formed, context-rich instructions every time, without manual intervention.
⨠Why Use Prompt Templates in Logic Apps?
Integrating Prompt Templates into your Logic Apps offers several advantages:
- Standardized Prompts:Â Keep your AI instructions consistent by defining the core logic in one template, rather than scattering variations throughout your workflow actions.
- Build Once, Use Often:Â Design a template for one report (like our leaderboard) and easily adapt or reuse it for other analytical tasks or across different Logic Apps.
- Simplified Updates:Â Need to refine the AI’s instructions? Modify the central template, without editing the entire flow.
- Seamless Data Integration:Â Connect the dots effortlessly. Data flowing through your Logic App (from triggers, storage, APIs, etc.) can be directly wired into your prompt template variables.
This approach streamlines the development of data-driven AI automations, making your solutions more robust and easier to manage.
đ§° Prerequisites
To build this, you’ll need:
- An Azure Logic App (Standard) resource.
- An Azure OpenAI resource with a deployed model (e.g., gpt-4).
- An Azure Blob Storage account to store the daily sales data (e.g., sales.json).
- A connection configured for Microsoft Teams in your Logic App.
- A connection configured for Azure Blob Storage.
- A connection configured for Azure OpenAI.
đ§ Build the Logic App workflow
Hereâs a breakdown of the key steps in the Logic App:
0.Build the Logic App workflow
- create workflow based on the steps showing below
1. Trigger: Recurrence
- Set to run daily to automate the report generation. You can specify interval
2. Action: Read blob content based on URI
- Add an action
- Search for Blob
- Connects to Azure Blob Storage.Â
Note: This connection uses managed identity. You must grant the “Storage Blob Data Contributor” role to this Logic App via your storage account’s Access Control (IAM) settings.
- Â
- Ensure the sales.json file is uploaded to your Azure Blob Storage.
- In the “Read blob content based on URI” configuration, set the Blob URI to the path of this file (e.g., mycontainer/myfolder/sales.json).
- Note: Enter the URI path without quotation marks.
3. Action: data (Compose)
- Takes the file content output from the previous step.
- We will create a ‘Compose’ component, then we rename it to ‘data’
- Our goal is to store the json file data in a compose component, it is helping us to monitor the data easier.
- This makes the data easily accessible for the prompt template.
As shown in the figure, click on the insert dynamic content (step 3 in the figure), and then choose Response from read blob action Content
Â
4. Action: question (Compose)
- Defines the core task for the AI.
- Similar to previous step, we need to create a compose component, we then call it question, then input is as below
- Input:Â [ { “role”: “user”, “content”: “Summaris sales data for me” } ]
- In this example, it’s a static input, but it could be made dynamic (e.g., taken from the trigger or another source).
5. Action: Get chat completions using Prompt Template
- Next action is to create an Azure OpenAI service, select Get chat completions using Prompt Template
- Connects to your Azure OpenAI service. You need to fill in the required parameters based on your Azure OpenAI Service portal.
Configuration:
- Deployment Identifier: Your AOAI model deployment name (e.g., gpt-4).
- Prompt Template: Contains the instructions, formatting rules, example output, and placeholders for dynamic data (data) and the user query (question). (See details below for the template).
- Prompt Template Variables: Maps the outputs from the data and question Compose actions to the variables used in the template. You need to choose Prompt Template Variable in order to be able to add your dynamic inputs for the prompt template.
You need to assign output of compose components as an input for your prompt template as shown in the figure below
Â
6. Action: Post message in a chat or channel
- Add a new action, search for Microsoft Teams and select Post message in a chat or channel
- Connects to Microsoft Teams by signing in into your account.
Note: You need to use your School or Corporate Microsoft Teams for this feature
- Sends the AI-generated summary.
- Configuration:
- Post As:Â Flow bot
- Post in:Â chat with Flow bot
- Recipient: Your email address
- Message: Insert output of your OpenAI response
Â
7.RUN
- Workflow is done and it is ready to be run. Here is the output you can get in Microsoft Teams
đ Prompt Template Details
The core of the AI generation lies in the prompt template provided to the Get chat completions using Prompt Template action. Let’s break it down:
system: You are a helpful assistant for a multi-branch restaurant business… Your job is to:
Generate a clear and engaging leaderboard-style summary for Microsoft Teams.
Start with a title: “đ Daily Branch Leaderboard – @{formatDateTime(convertTimeZone(utcNow(), ‘UTC’, ‘Europe/Dublin’), ‘MMMM,d,yyyy’)}rn}”
Briefly summarize how the branches performed in ranked order…
Use emojis…
Highlight top performers…
Be sure that you are using n between each two branch names…
#Example for generating response:
đ Daily Branch Leaderboard â May 5, 2025
Hereâs how your branches performed today:
1ď¸âŁ Galway Bay â đĽ Top performer…
2ď¸âŁ Dublin Central â Strong sales…
# Data
# Branch Sales Data
Here is the branch sales data…
{% for branch in data %}
Branch ID: {{branch.BranchID}}
Branch Name: {{branch.BranchName}}
Total Sales (âŹ): {{branch.TotalSalesEuro}}
…
{% endfor %}
# Question The employee has asked the following:
{% for item in question %}
{{item.role}}:
{{item.content}}
{% endfor %}
- system::Â Sets the persona and overall goal for the AI.
- :Â Provides specific rules for formatting, tone, and content.
- @{formatDateTime(…)}}:Â Logic Apps expression to dynamically insert the current date.
- :Â Shows the desired output format.
- :Â Defines how the input data should be structured for the AI.
- {% for branch in data %}:Â Jinja loop iterates through the branch data read from the blob.
- {{ branch.BranchName }}Â etc.:Â Jinja placeholders inject specific data fields for each branch.
- : Injects the question defined in the question Compose action.
This structured template ensures the AI receives all necessary context and instructions to generate the desired leaderboard summary consistently.
â Final Output
When the Logic App runs, it will post a message similar to the example provided in the prompt template directly into the specified Teams chat or channel, providing a clear, concise, and engaging daily performance summary.
đŹ Feedback
Let me know if you found this helpful or have ideas for other Logic Apps + AI automation scenarios!