![Building on Mendix with Gen AI models from Amazon Bedrock](https://assets.community.aws/a/2hgHL3lnnsxaY5inb9iYF7CJQeO/AWS-.webp)
Building on Mendix with Gen AI models from Amazon Bedrock
In this tutorial, you'll learn how to create a Mendix application to prompt an Anthropic Claude model in Amazon Bedrock and display its responses.
Published Jun 10, 2024
Last Modified Jun 18, 2024
Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies like AI21 Labs, Anthropic, Cohere, Meta, Mistral AI, Stability AI, and Amazon through a single API, along with a broad set of capabilities you need to build generative AI applications with security, privacy, and responsible AI.
Mendix is a low-code application development platform used by businesses in manufacturing, banking and other verticals to develop apps at scale
In this tutorial, you will build a Mendix application which will enable you to prompt an Anthropic Claude model in Amazon Bedrock and display its responses.
- An active AWS account
- Mendix Studio Pro 10.6.1 or above installed on your computer
- This workshop will run us_east_1 AWS region
- Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies.
- AWS Identity and Access Management (IAM) helps you securely manage access to your AWS resources by controlling who is authenticated and authorized to use them.
- Mendix is a low-code application development platform from Siemens, an AWS partner. Mendix is used by businesses in manufacturing, banking and other verticals to develop apps at scale.
1. On the AWS IAM console, create user named mendix-user (see instructions here)
2. On the AWS IAM console, create access keys for mendix-user (see instructions here
1. Create an IAM policy to mendix-user to utilize Amazon Bedrock. Here’s an example policy:
2. Attach the policy to mendix-user.
For this tutorial only, we use the policy above. However, for other cases, we recommend using a more restrictive following least privilege principle.
1. Launch Mendix Studio Pro and sign in into Mendix Studio Pro
2. Under Studio Pro, choose Create New App.
3. Under Choose your starting point, choose Blank Web App, and then choose Use this starting point.
4. In App Settings enter AWSApp for App name & choose Create app.
5. Create a folder named BedrockModel in the newly created module.
The following versions for Mendix connectors were tested for this tutorial:
- AWSAuthentication 3.0.2
- Amazon Bedrock Connector 2.3.0
- Amazon Bedrock Implementation Example 2.1.0
- Community Commons 10.0.5
1. Choose the shopping cart icon on the top right-hand side corner of Studio Pro to open the Mendix Marketplace.
2. In the search field, enter AWS Authentication Connector and choose on the first search result.
3. Choose Download, and then choose Import on the popup that opens and afterwards confirm the information message by choosing OK.
4. Search for Amazon Bedrock Connector in the Mendix marketplace
5. Follow steps 1 through 4 for other connectors
![Amazon Connectors on Mendix](https://assets.community.aws/a/2hgDLAMQypZJOfhtI9XoNoxb53E/scre.webp)
1. In the App Explorer, expand the App AWSApp section and double-click on Settings to open the App Settings in a popup.
2. We need to create a new configuration profile. Choose New to create a new configuration, which will open a popup and name it AWSCredentials.
3. Navigate to the Constants tab and choose New.
4. In the search field, type AccessKey, select the AccessKey constant of the AWSAuthentication connector, and choose Select.
5. In the popup that opens, enter your Access Key in the Value field and confirm with OK.
6. Choose New one more time and this time search for SecretAccessKey, select the SecretAccessKey constant of the AWSAuthenticationConnector, and then choose Select.
7. Enter your Secret Access Key and choose OK and OK again to save your configuration.
8. Make sure, that your configuration is set to Active. You can confirm that by checking the active column has a green check mark.
9. Choose Ok to escape the App Settings.
![AWS Credentials in Mendix](https://assets.community.aws/a/2hgDWqDe5eBSYKpOroHHeKaWU29/scre.webp)
1. In the Amazon Bedrock console, in us_east_1 region, choose Model access.
2. Choose Manage model access, then select the models Claude and Claude Instant then choose Save changes
![Model acces via Amazon Bedrock](https://assets.community.aws/a/2hgE1JZODy2MaxQoC1mQGfKdcsL/scre.webp)
1. In the App Explorer, under AWSApp, double click on Navigation
2. Change home page by selecting Home_Web, under Marketplace modules -> AmazonBedrockExampleImplementation -> Pages
3. In Menu, click on New Item,
- In Caption, enter Claude
- In Icon, press Select. In Filter, type message and select message-bubble icon
- In On Click, select Call a microflow.
- In Search, type NAV_ChatPrompt and select NAV_ChatPrompt_Overview
- Click on OK
Configuring mendix navigation page
1. Open ACT_InvokeClaudeModel microflow located in Marketplace modules -> AmazonBedrockExampleImplementation -> Pages -> ChatPrompt
2. In the ACT_InvokeClaudeModel microflow, Double click on ChatPrompt_wHistory microflow call
3. Double click on region and change the expression to AWSAuthentication.ENUM_Region.us_east_1
4. Click Ok and Ok to save the new expression
![Configure ACT_InvokeClaudeModel microflow](https://assets.community.aws/a/2hgEN3SBqRvq5VFh7Ve6rhCVjDT/scre.webp)
Press on the green triangle located at the top bar to run your application locally.
1. When application is built, click on view app. This will open tab on your browser showing the app
2. Navigate the Claude page by click on message bubble box
3. In the input field, ask a question to Claude. For instance:
“Can you tell me what is the best way to travel to Morocco from South Africa?”
![Mendix app leveraging Claude model on Amazon Bedrock](https://assets.community.aws/a/2hgEl8Htq54tkCx5JnXKWPpwc1a/scre.webp)
1. Navigate to the AWS IAM console
2. In the left menu, choose Users.
3. Choose mendix-user, and then choose Delete
4. Under To confirm deletion, enter mendix-user, and then choose Delete user.
1. In the Amazon Bedrock console, in us_east_1 region choose Model access.
2. Choose Modify model access, then Unselect the models Claude and Claude Instant
3. Click and Submit
![Remove Model access on Amazon Bedrock](https://assets.community.aws/a/2hgFCgGdyMRaq5gCcrxd3HnCqcs/scre.webp)