Skip to content

Commit 50e1e91

Browse files
author
ecfan
committed
Draft updates
1 parent 7e7932e commit 50e1e91

File tree

4 files changed

+166
-11
lines changed

4 files changed

+166
-11
lines changed

articles/logic-apps/create-chat-assistant-prompt-template-standard-workflow.md

Lines changed: 166 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ ms.date: 04/21/2025
2323
2424
Suppose you want to automate the way that your enterprise or organization answers questions from various groups of people, such as employees, customers, investors, or the media. You can build a chat assistant that responds to questions by using data available from your enterprise or organization.
2525

26-
When you use your own data with the models in Azure OpenAI Service, you create a powerful AI-powered conversational platform that provides faster communication and draws context from specific domain knowledge. To build the process that handles questions, accesses your data, and returns responses, you can create a Standard workflow in Azure Logic Apps to automate and perform the necessary steps - all without writing code.
26+
When you use your own data with the models in Azure OpenAI Service, you create a powerful AI-powered conversational platform that provides faster communication and draws context from specific domain knowledge. To build the process that handles each question, accesses your data source, and returns a response, you can create a Standard workflow in Azure Logic Apps to automate the necessary steps - all without writing code.
2727

28-
This guide shows how to build a chat assistant by using a *prompt template* as your starting point. This template is a prebuilt reusable text-based structure that guides the interactions between the AI model and questioners.
28+
This guide shows how to build a chat assistant by using a *prompt template* as your starting point. This template is a prebuilt reusable text-based structure that guides the interactions between the AI model and the questioners.
2929

3030
The following diagram shows the example workflow that this guide creates:
3131

@@ -64,13 +64,13 @@ The example workflow uses the following operations:
6464
|-----------|-------------|
6565
| Built-in trigger named **When an HTTP request is available** | Waits for a external caller to send an HTTPS request. This request fires the trigger to start the workflow and passes in a serialized token string with the inputs for the workflow actions. |
6666
| Several **Compose** built-in actions | These actions store the following test data: <br><br>- **Question**: The question asked. <br><br>- **Product catalog**: Internal product catalog entries. <br><br>- **Employee**: Employee profile and past procurement orders. |
67-
| Built-in action named **Get chat completions using Prompt Template** | |
67+
| Built-in action named **Get chat completions using Prompt Template** | Gets [chat completions](/azure/ai-services/openai/how-to/chatgpt) for the specified prompt template. For more information, see [Get chat completions using prompt template](/azure/logic-apps/connectors/built-in/reference/openai/#get-chat-completions-using-prompt-template-(preview)).
6868

6969
> [!TIP]
7070
>
71-
> When you have the choice, always choose the built-in ("in app") operation over the managed ("shared") version.
72-
> The built-in version runs inside the Azure Logic Apps runtime to reduce latency and provides better performance
73-
> and control over authentication.
71+
> When you have the choice, always choose the built-in ("in app") operation over the
72+
> managed ("shared") version. The built-in version runs inside the Azure Logic Apps
73+
> runtime to reduce latency and provides better performance and control over authentication.
7474
7575
This example creates and uses a prompt template that lets your workflow complete the following tasks:
7676

@@ -90,32 +90,187 @@ To following along with the example, get the [sample prompt template and inputs]
9090

9191
- An [Azure OpenAI Service resource](/azure/ai-services/openai/how-to/create-resource?pivots=web-portal) with a deployed GPT model such as GPT-3.5 or GP-4.
9292

93-
- To chat with your own data by using the Azure OpenAI Service models, you have to create an Azure AI Foundry project and add your own data source. For more information, see the following documentation:
93+
- The example in this how-to guide provides test data that you can use to try out the workflow. To chat with your own data by using the Azure OpenAI Service models, you have to create an Azure AI Foundry project and add your own data source. For more information, see the following documentation:
9494

9595
- [Quickstart: Chat with Azure OpenAI models using your own data](/azure/ai-services/openai/use-your-data-quickstart)
9696

9797
- [Getting started with customizing a large language model (LLM)](/azure/ai-services/openai/concepts/customizing-llms)
9898

99-
- When you add the **Azure OpenAI** action to your workflow, you can create a connection to your Azure OpenAI Service resource. You'll need the endpoint URL for your **Azure OpenAI Service** resource and the following information, based on the authentication type that you choose:
99+
- When you add the **Azure OpenAI** action to your workflow, you can create a connection to your Azure OpenAI Service resource. You'll need the endpoint URL for your **Azure OpenAI Service** resource and the following information, based on the selected [authentication type](/azure/logic-apps/connectors/built-in/reference/openai/#authentication):
100100

101101
| Authentication type | Requirements |
102102
|---------------------|--------------|
103103
| **URL and key-based authentication** | 1. Go to your **Azure OpenAI Service** resource. <br><br>2. On the resource menu, under **Resource Management**, select **Keys and Endpoint**. <br><br>3. Copy the **Endpoint** URL and either **Key** value. Store these values somewhere safe. |
104-
| **Active Directory OAuth** | Set up your logic app resource for [OAuth 2.0 with Microsoft Entra ID authentication](/entra/architecture/auth-oauth2). |
105-
| **Managed identity** | 1. Follow [these steps to set up the managed identity for your logic app and access to your Azure OpenAI resource](/azure/logic-apps/authenticate-with-managed-identity?tabs=standard). <br><br>2. Go to your **Azure OpenAI Service** resource. <br><br>3. On the resource menu, under **Resource Management**, select **Keys and Endpoint**. <br><br>4. Copy the **Endpoint** URL. Store this value somewhere safe. |
104+
| **Active Directory OAuth** | 1. Set up your logic app resource for [OAuth 2.0 with Microsoft Entra ID authentication](/entra/architecture/auth-oauth2). <br><br>2. Go to your **Azure OpenAI Service** resource. <br><br>3. On the resource menu, under **Resource Management**, select **Keys and Endpoint**. <br><br>4. Copy the **Endpoint** URL. Store this value somewhere safe. |
105+
| **Managed identity** <br>(Recommended) | 1. Follow [these steps to set up the managed identity with Microsoft Entra ID for your logic app](/azure/logic-apps/authenticate-with-managed-identity?tabs=standard). <br><br>2. Go to your **Azure OpenAI Service** resource. <br><br>3. On the resource menu, under **Resource Management**, select **Keys and Endpoint**. <br><br>4. Copy the **Endpoint** URL. Store this value somewhere safe. |
106+
107+
[!INCLUDE [highest-security-level-guidance](includes/highest-security-level-guidance.md)]
106108

107109
## Add a trigger
108110

111+
To add the operation that starts your workflow when an event happens or a condition is met, follow these steps:
112+
109113
1. Sign in to the [Azure portal](https://portal.azure.com) with your Azure account credentials.
110114

111115
1. Open your Standard logic app resource and blank workflow in the designer.
112116

117+
1. Follow [these steps to add the trigger you want](/azure/logic-apps/create-workfklow-with-trigger-or-action?tabs=standard#add-trigger).
118+
119+
This example uses the built-in ("in app") trigger named **When an HTTP request is available**.
120+
121+
For more information, see [Receive and respond to inbound HTTPS calls](/azure/connectors/connectors-native-reqres?tabs=standard).
122+
123+
1. Save your workflow. On the toolbar, select **Save**.
124+
125+
After you save your workflow, in the **Request** trigger, an automatically generated *callback URL* appears in the **HTTP URL** parameter. This endpoint URL is the location where external callers can send an HTTPS request to trigger the workflow and provide inputs for the workflow.
126+
127+
> [!WARNING]
128+
>
129+
> The endpoint URL includes a Shared Access Signature (SAS) key that gives anyone with the URL
130+
> the capability to trigger the workflow and pass along any data they want. For information about
131+
> protecting and securing the workflow, see [Secure access and data in workflows](/azure/logic-apps/logic-apps-securing-a-logic-app?tabs=azure-portal#generate-a-shared-access-signature-sas-key-or-token).
132+
133+
When you're done, your workflow looks like the following example:
134+
135+
:::image type="content" source="media/create-chat-assistant-prompt-template-standard-workflow/request-trigger.png" alt-text="Screenshot shows the Standard workflow designer and the Request trigger." lightbox="media/create-chat-assistant-prompt-template-standard-workflow/request-trigger.png":::
136+
137+
## Add the Compose actions
138+
139+
To add operations that store the trigger outputs for subsequent actions to use as inputs, follow these steps:
140+
141+
1. Under the trigger, follow [these steps to add the data operation named **Compose** action](/azure/logic-apps/create-workfklow-with-trigger-or-action?tabs=standard#add-action).
142+
143+
This example adds three **Compose** actions and uses the following test data as inputs:
144+
145+
1. Rename the first **Compose** action to **Question**, and enter the following data in the **Inputs** box:
146+
147+
```json
148+
[
149+
{
150+
"role": "user",
151+
"content": "When did we last order laptops for new hires in IT?"
152+
}
153+
]
154+
```
155+
156+
1. Rename the next **Compose** action to **Product catalog**, and enter the following data in the **Inputs** box:
157+
158+
```json
159+
[
160+
{
161+
"id": "1",
162+
"title": "Dell Latitude 5540 Laptop",
163+
"content": "Intel i7, 16GB RAM, 512GB SSD, standard issue for IT new hire onboarding"
164+
},
165+
{
166+
"id": "2",
167+
"title": "Docking Station",
168+
"content": "Dell WD19S docking stations for dual monitor setup"
169+
}
170+
]
171+
```
172+
173+
1. Rename the final **Compose** action as **Employee**, and enter the following data in the **Inputs** box:
174+
175+
```json
176+
{
177+
"firstName": "Sophie",
178+
"lastName": "Owen",
179+
"department": "IT",
180+
"employeeId": "E12345",
181+
"orders": [
182+
{
183+
"name": "Dell Latitude 5540 Laptop",
184+
"description": "Ordered 15 units for Q1 IT onboarding",
185+
"date": "2024/02/20"
186+
},
187+
{
188+
"name": "Docking Station",
189+
"description": "Bulk purchase of 20 Dell WD19S docking stations",
190+
"date": "2024/01/10"
191+
}
192+
]
193+
}
194+
```
195+
196+
When you're done, your workflow looks like the following example:
197+
198+
:::image type="content" source="media/create-chat-assistant-prompt-template-standard-workflow/compose-actions.png" alt-text="Screenshot shows the Standard workflow designer, Request trigger, and three renamed Compose actions." lightbox="media/create-chat-assistant-prompt-template-standard-workflow/compose-actions.png":::
113199

200+
Now, add the Azure OpenAI action to the workflow.
114201

115202
## Add the Azure OpenAI action
116203

117-
1.
204+
1. Under the last **Compose** action, follow [these steps to add the **Azure OpenAI** action named **Get chat completions using Prompt Template**](/azure/logic-apps/create-workfklow-with-trigger-or-action?tabs=standard#add-action).
205+
206+
1. After the action appears on the designer surface, the connection pane opens so that you can provide the following information:
207+
208+
| Parameter | Required | Value | Description |
209+
|-----------|----------|-------|-------------|
210+
| **Connection Name** | Yes | <*connection-name*> | The name for the connection to your Azure OpenAI resource. |
211+
| **Authentication Type** | Yes | See the following sections: <br><br>- [Prerequisites](#prerequisites) <br>- [Azure OpenAI built-in connector authentication](/azure/logic-apps/connectors/built-in/reference/openai/#authentication) | The authentication type to use with the connection. |
212+
| **Azure OpenAI Endpoint URL** | Yes | <*endpoint-URL-Azure-OpenAI-resource*> | The endpoint URL for your Azure OpenAI resource. For more information, see [Prerequisites](#prerequisites). |
213+
| **Authentication Key** | Required only for **URL and key-based authentication** | <*access-key*> | See the following sections: <br><br>- [Prerequisites](#prerequisites) <br>- [Azure OpenAI built-in connector authentication](/azure/logic-apps/connectors/built-in/reference/openai/#authentication) |
214+
215+
1. When you're done, select **Create new**.
216+
217+
1. After the action pane opens, provide the following information to use for the prompt template:
218+
219+
| Parameter | Value | Description |
220+
|-----------|-------|-------------|
221+
| **Deployment Identifier** | - **gpt-4o** <br>- **gpt-35** | The deployed model name. |
222+
| **Prompt Template** | <*template-text*> | The prompt template, which uses Prompty liquid format. For more information, see the following documentation: <br><br>- [Get chat completions using Prompt Template](/azure/logic-apps/connectors/built-in/reference/openai/#get-chat-completions-using-prompt-template-(preview)) |
223+
224+
For this example, replace the example template text with the following sample text:
225+
226+
```
227+
system:
228+
You are an AI assistant for Contoso's internal procurement team. You help employees get quick answers about previous orders and product catalog details. Be brief, professional, and use markdown formatting when appropriate. Include the employee’s name in your response for a personal touch.
229+
230+
# Product Catalog
231+
Use this documentation to guide your response. Include specific item names and any relevant descriptions.
232+
233+
{% for item in documents %}
234+
Catalog Item ID: {{item.id}}
235+
Name: {{item.title}}
236+
Description: {{item.content}}
237+
{% endfor %}
238+
239+
# Order History
240+
Here is the employee's procurement history to use as context when answering their question.
241+
242+
{% for item in customer.orders %}
243+
Order Item: {{item.name}}
244+
Details: {{item.description}} — Ordered on {{item.date}}
245+
{% endfor %}
246+
247+
# Employee Info
248+
Name: {{customer.firstName}} {{customer.lastName}}
249+
Department: {{customer.department}}
250+
Employee ID: {{customer.employeeId}}
251+
252+
# Question
253+
The employee has asked the following:
254+
255+
{% for item in question %}
256+
{{item.role}}:
257+
{{item.content}}
258+
{% endfor %}
259+
260+
Based on the product documentation and order history above, please provide a concise and helpful answer to their question. Do not fabricate information beyond the provided inputs.
261+
```
262+
263+
1. For other parameters, see [Get chat completions using Prompt Template](/azure/logic-apps/connectors/built-in/reference/openai/#get-chat-completions-using-prompt-template-(preview)).
264+
265+
When you're done, your workflow looks like the following example:
266+
267+
:::image type="content" source="media/create-chat-assistant-prompt-template-standard-workflow/chat-completions-prompt-template.png" alt-text="Screenshot shows the Standard workflow designer, Request trigger, three renamed Compose actions, and the Azure OpenAI built-in action, Get chat completions using Prompt Template." lightbox="media/create-chat-assistant-prompt-template-standard-workflow/chat-completions-prompt-template.png":::
268+
269+
## Test your workflow
270+
271+
## Delete your resources
118272
119273
120274
## Related content
121275
276+
- [Connect to Azure AI services from workflows in Azure Logic Apps](/azure/logic-apps/connectors/azure-ai)
Loading
43.8 KB
Loading
36.7 KB
Loading

0 commit comments

Comments
 (0)