|
| 1 | +--- |
| 2 | +title: "Build a Chatbot Using the AI Bot Starter App" |
| 3 | +url: /appstore/modules/genai/using-genai/starter-template |
| 4 | +linktitle: "Build a Chatbot Using the AI Bot Starter App" |
| 5 | +weight: 10 |
| 6 | +description: "A tutorial that describes how to get started building a smart app with a starter template" |
| 7 | +--- |
| 8 | + |
| 9 | +## Introduction |
| 10 | + |
| 11 | +This document guides on building a smart app using a starter template. Alternatively, you can create your smart app from scratch using a blank GenAI app template. For more details, see [Build a Smart App from a Blank GenAI App](/appstore/modules/genai/using-genai/blank-app/). |
| 12 | + |
| 13 | +### Prerequisites |
| 14 | + |
| 15 | +Before starting this guide, make sure you have completed the following prerequisites: |
| 16 | + |
| 17 | +* Intermediate knowledge of the Mendix platform: Familiarity with Mendix Studio Pro, microflows, and modules is required. |
| 18 | + |
| 19 | +* Basic understanding of GenAI concepts: Review the [Enrich Your Mendix App with GenAI Capabilities](/appstore/modules/genai/) page to gain foundational knowledge and become familiar with the key [concepts](/appstore/modules/genai/get-started/). |
| 20 | + |
| 21 | +* Understanding Large Language Models (LLMs) and Prompt Engineering: Learn about [LLMs](/appstore/modules/genai/get-started/#llm) and [prompt engineering](/appstore/modules/genai/get-started/#prompt-engineering) to effectively use these within the Mendix ecosystem. |
| 22 | + |
| 23 | +### Learning Goals |
| 24 | + |
| 25 | +By the end of this document, you will: |
| 26 | + |
| 27 | +* Understand the core concepts of Generative AI and its integration with the Mendix platform. |
| 28 | + |
| 29 | +* Build your first augmented Mendix application using GenAI starter apps and connectors. |
| 30 | + |
| 31 | +* Develop a solid foundation for leveraging GenAI capabilities to address common business use cases. |
| 32 | + |
| 33 | +## Building Your Smart App with a Starter Template |
| 34 | + |
| 35 | +To simplify your first use case, start building a chatbot using the [AI Bot Starter App](https://marketplace.mendix.com/link/component/227926). This pre-built template streamlines the process, allowing you to quickly integrate AI capabilities into your application. You can see the result in the image below. |
| 36 | + |
| 37 | +{{< figure src="/attachments/appstore/platform-supported-content/modules/genai/genai-howto-starterapp/starter_genai_interface.jpg" >}} |
| 38 | + |
| 39 | +### Choosing the Infrastructure |
| 40 | + |
| 41 | +Selecting the infrastructure for integrating GenAI into your Mendix application is the first step. Depending on your use case and preferences, you can choose from the following options: |
| 42 | + |
| 43 | +* [OpenAI](/appstore/modules/genai/openai/): The [OpenAI Connector](https://marketplace.mendix.com/link/component/220472?_gl=1*1gbywo4*_gcl_au*NjUwMzI0NzA0LjE3MzI2MjkxMTI.) supports OpenAI’s platform and Azure’s OpenAI service. |
| 44 | + |
| 45 | +{{% alert color="info" %}} |
| 46 | +To start, you can sign up for a free trial with OpenAI and receive credits valid for three months from the account creation date. For more details, see the [OpenAI API reference](https://platform.openai.com/docs/api-reference/authentication). |
| 47 | +{{% /alert %}} |
| 48 | + |
| 49 | +* [Amazon Bedrock](/appstore/modules/genai/bedrock/): The [Bedrock Connector](https://marketplace.mendix.com/link/component/215042?_gl=1*yogwo1*_gcl_au*NjUwMzI0NzA0LjE3MzI2MjkxMTI.) allows you to leverage Amazon Bedrock’s fully managed service to integrate foundation models from Amazon and leading AI providers. |
| 50 | + |
| 51 | +* Your Own Connector: Optionally, if you prefer a custom connector, you can integrate your chosen infrastructure. However, this document focuses on the OpenAI and Bedrock connectors, as they offer comprehensive support and ease of use to get started. |
| 52 | + |
| 53 | +### Getting Started |
| 54 | + |
| 55 | +Download the [AI Bot Starter App](https://marketplace.mendix.com/link/component/227926) from the Marketplace and configure the **encryption key** in the **App Settings**. Follow the steps below based on the infrastructure you chose. |
| 56 | + |
| 57 | +#### OpenAI Configuration |
| 58 | + |
| 59 | +Follow the steps below to configure OpenAI for your application. For more information, see the [Configuration](/appstore/modules/genai/openai/#configuration) section of the *OpenAI*. |
| 60 | + |
| 61 | +1. Run the application locally. |
| 62 | + |
| 63 | +2. Configure OpenAI Settings: |
| 64 | + |
| 65 | + * In the chatbot-like application interface, go to the **Settings** ({{% icon name="cog" %}}) icon, and find the **OpenAI Configuration**. |
| 66 | + * Click **New** and provide the following details: |
| 67 | + * **Display Name**: A reference name to identify this configuration (for example, "My OpenAI Configuration"). |
| 68 | + * **API Type**: Choose between **OpenAI** or **Azure OpenAI**. |
| 69 | + * **Endpoint**: Enter the endpoint URL for your selected API type. |
| 70 | + * **Token**: Provide the API key for authentication. |
| 71 | + * If using Azure OpenAI, add: |
| 72 | + * **Deployment Name**: Specify the deployed model (for example, *gpt-4o*, *gpt-3.5-turbo*, etc.) |
| 73 | + * **API Version**: Provide the version of the API you are using (for example, *2024-06-01*, *2024-10-21*, etc.) |
| 74 | + |
| 75 | + * Click **Save** to store your configuration. |
| 76 | + |
| 77 | +3. Test the Configuration: |
| 78 | + |
| 79 | + * Select the configuration you created, and click **Test Configuration**. |
| 80 | + * If an error occurs, check the **Mendix Console** for more details on resolving the issue. |
| 81 | + |
| 82 | +#### Bedrock Configuration |
| 83 | + |
| 84 | +Follow the steps below to configure Amazon Bedrock for your application: |
| 85 | + |
| 86 | +1. Set Up AWS credentials: |
| 87 | + |
| 88 | + * Navigate to **App Settings** > **Configurations** in Studio Pro. |
| 89 | + * Go to the **Constants** tab and add the following (In this example, static credentials are used. For more details on the temporary credentials, see the [Implementing Temporary Credentials](/appstore/modules/aws/aws-authentication/#session) section of the *AWS Authentication*). |
| 90 | + |
| 91 | + * `AWSAuthentication.AccessKey`: Enter the access key obtained from the Amazon Bedrock console. |
| 92 | + * `AWSAuthentication.SecretAccessKey`: Enter the secret access key from the Amazon Bedrock console. |
| 93 | + |
| 94 | + * Save your changes. |
| 95 | + |
| 96 | +2. Run the application locally. |
| 97 | + |
| 98 | +3. Configure Bedrock settings: |
| 99 | + |
| 100 | + * In the chatbot-like application interface, go to **Administration** > **Amazon Bedrock Configuration**. |
| 101 | + * Click **New/Edit** and provide the following details: |
| 102 | + * **Region**: Select the AWS region where your Bedrock service is hosted. |
| 103 | + * **Use Static Credentials**: Enable this option if you are using static AWS credentials configured in the app. |
| 104 | + * Click **Save & Sync Data** to ensure your changes are applied. |
| 105 | + |
| 106 | +### Bot Configuration |
| 107 | + |
| 108 | +Before starting the bot configuration, ensure that the OpenAI or Bedrock configuration is complete. |
| 109 | + |
| 110 | +1. In the **Administration** menu, go to the **Bot Configuration**, and click **New**. |
| 111 | +2. Enter the following details: |
| 112 | + |
| 113 | + * **Display Name**: A reference name for the bot configuration (for example, "Configuration Bot"). |
| 114 | + * **Architecture**: Select **OpenAI** or **Bedrock** based on your choice. |
| 115 | + * **Is Selectable in UI**: Enable this option to allow the end user to select this configuration. |
| 116 | + * **Configuration**: Select the OpenAI or Bedrock configuration you just created. |
| 117 | + * **Action Microflow**: Choose the provided microflow, `ChatContext_ChatWithHistory_ActionMicroflow`. |
| 118 | + |
| 119 | +3. Save your changes, and optionally set it as the default bot configuration by selecting **Make Default** on the Bot Configuration page. |
| 120 | + |
| 121 | +## Testing and Troubleshooting |
| 122 | + |
| 123 | +Follow the steps below to test the chatbot: |
| 124 | + |
| 125 | +1. Navigate to the **Chat** option in the top menu to open the chatbot interface. |
| 126 | +2. In the **Configuration** box: |
| 127 | + * Select your bot configuration. |
| 128 | + * Optionally, choose instructions for the LLM to follow. |
| 129 | +3. Start interacting with your chatbot by typing in the chat box. |
| 130 | +4. For additional testing, create a custom instruction for the LLM, such as: 'You are a travel advisor assistant. Your role is to provide travel tips and destination information.' |
| 131 | + |
| 132 | +Congratulations! Your chatbot is now ready to use. |
| 133 | + |
| 134 | +If an error occurs, check the **Mendix Console** in Studio Pro for details to help resolve the issue. |
0 commit comments