|
| 1 | +--- |
| 2 | +title: Create AI chat assistants with prompt templates |
| 3 | +description: Build an AI chat assistant that answers questions using your own data with Standard workflows in Azure Logic Apps and Azure OpenAI prompt templates. |
| 4 | +services: logic-apps |
| 5 | +ms.suite: integration |
| 6 | +ms.reviewers: estfan, shahparth, azla |
| 7 | +ms.topic: how-to |
| 8 | + |
| 9 | +ms.collection: ce-skilling-ai-copilot |
| 10 | +ms.date: 04/21/2025 |
| 11 | + |
| 12 | +# CustomerIntent: I want to learn how to create an AI-powered chat assistant by using a prompt template that makes answering questions easier. I want to know how to complete this task by building a Standard workflow that connects to an Azure OpenAI resource and uses the Azure OpenAI built-in chat completions operation with a prompt template in Azure Logic Apps. |
| 13 | +--- |
| 14 | + |
| 15 | +# Create an AI chat assistant by using prompt templates with Standard workflows in Azure Logic Apps (Preview) |
| 16 | + |
| 17 | +[!INCLUDE [logic-apps-sku-standard](../../includes/logic-apps-sku-standard.md)] |
| 18 | + |
| 19 | +> [!NOTE] |
| 20 | +> |
| 21 | +> This capability is in preview and is subject to the |
| 22 | +> [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/). |
| 23 | +
|
| 24 | +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. |
| 25 | + |
| 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. |
| 27 | + |
| 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. |
| 29 | + |
| 30 | +The following diagram shows the example workflow that this guide creates: |
| 31 | + |
| 32 | +:::image type="content" source="media/create-chat-assistant-prompt-template-standard-workflow/overview.png" alt-text="Screenshot shows Azure portal, Standard workflow designer, and operations that create an example chat assistant." lightbox="media/create-chat-assistant-prompt-template-standard-workflow/overview.png"::: |
| 33 | + |
| 34 | +For more information about the operations in this workflow, see [Review the example scenario](#review-the-example-scenario). |
| 35 | + |
| 36 | +Templates provide the following benefits for creating effective, useful, and clear prompts that align with specific use cases: |
| 37 | + |
| 38 | +| Benefit | Description | |
| 39 | +|---------|-------------| |
| 40 | +| **Consistency** | Centralize prompt logic, rather than embed prompt text in each action. | |
| 41 | +| **Reusability** | Apply the same prompt across multiple workflows. | |
| 42 | +| **Maintainability** | Tweak prompt logic in a single place without editing the entire flow. | |
| 43 | +| **Dynamic control** | Workflow inputs directly pass into the template, for example, values from a form, database, or API. | |
| 44 | + |
| 45 | +All these benefits help you create adaptable AI-driven flows that are suitable for scalable enterprise automation - without duplicating effort. |
| 46 | + |
| 47 | +For more information, see the following documentation: |
| 48 | + |
| 49 | +- [What is Azure Logic Apps](/azure/logic-apps/logic-apps-overview)? |
| 50 | +- [What is Azure OpenAI Service](/azure/ai-services/openai/overview)? |
| 51 | + |
| 52 | +## Review the example scenario |
| 53 | + |
| 54 | +This guide uses an example scenario that creates a chat assistant for an IT team. Among other responsibilities, the team procures hardware such as laptops for the company's employees. The requirements for this assistant include the following tasks: |
| 55 | + |
| 56 | +- Accept a question that uses natural language and understands context. |
| 57 | +- Read and search structured data such as past orders and catalog details. |
| 58 | +- Pass the results into a prompt template by using Jinja2 syntax to dynamically inject data at runtime. |
| 59 | +- Generate a polished and professional response. |
| 60 | + |
| 61 | +The example workflow uses the following operations: |
| 62 | + |
| 63 | +| Operation | Description | |
| 64 | +|-----------|-------------| |
| 65 | +| 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. | |
| 66 | +| 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** | | |
| 68 | + |
| 69 | +> [!TIP] |
| 70 | +> |
| 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. |
| 74 | +
|
| 75 | +This example creates and uses a prompt template that lets your workflow complete the following tasks: |
| 76 | + |
| 77 | +- Define a prompt with placeholders such as **`{{ customer.orders }}`**. |
| 78 | +- Automatically populate the template with outputs from earlier actions in the workflow. |
| 79 | +- Generate consistent and structured prompts with minimal effort. |
| 80 | + |
| 81 | +To following along with the example, get the [sample prompt template and inputs](https://github.com/Azure/logicapps/tree/shahparth-lab-patch-2/AI-sample-demo) from the Azure Logic Apps GitHub repo. The example assumes that you're simulating procurement data with test inputs. |
| 82 | + |
| 83 | +## Prerequisites |
| 84 | + |
| 85 | +- An Azure account and subscription. If you don't have an Azure subscription, [sign up for a free Azure account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
| 86 | + |
| 87 | +- A Standard logic app resource with a blank *stateful* workflow, which stores run history and the values for variables, inputs, and outputs that you can use for testing. |
| 88 | + |
| 89 | + To create this resource and workflow, see [Create an example Standard logic app workflow using the Azure portal](/azure/logic-apps/create-single-tenant-workflows-azure-portal). |
| 90 | + |
| 91 | +- 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. |
| 92 | + |
| 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: |
| 94 | + |
| 95 | + - [Quickstart: Chat with Azure OpenAI models using your own data](/azure/ai-services/openai/use-your-data-quickstart) |
| 96 | + |
| 97 | + - [Getting started with customizing a large language model (LLM)](/azure/ai-services/openai/concepts/customizing-llms) |
| 98 | + |
| 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: |
| 100 | + |
| 101 | + | Authentication type | Requirements | |
| 102 | + |---------------------|--------------| |
| 103 | + | **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. | |
| 106 | + |
| 107 | +## Add a trigger |
| 108 | + |
| 109 | +1. Sign in to the [Azure portal](https://portal.azure.com) with your Azure account credentials. |
| 110 | + |
| 111 | +1. Open your Standard logic app resource and blank workflow in the designer. |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +## Add the Azure OpenAI action |
| 116 | + |
| 117 | +1. |
| 118 | + |
| 119 | + |
| 120 | +## Related content |
| 121 | + |
0 commit comments