How to create a chatbot in mendix integrated with Gen AI

0
I want to build a chatbot in Mendix 10.21 that: Lets users ask questions in natural language (Ex  “Show mobiles under 20000”) Uses ChatGPT (via OpenAI Connector v5.2.0) to understand the question Converts that question into structured data (like category = mobile, price < 20000) Uses that (Local Database) data to search a PostgreSQL database Displays the results back in your Mendix app
asked
2 answers
0

Hi Mallikarjun Jaggarapu,

 

the GenAI Showcase App covers a lot of examples to integrate AI into a Mendix application. Some of the examples demonstrate patterns that you might find useful.

 

To build your use case, there are a few options that you can discover:

  1. Function calling: the model can call a microflow that takes care of mapping the user's request to your entity structure, for example by having input parameter "Category" and retrieve the data from the Mendix database. 
  2. System Prompt: you can instruct the model to create the output tailored to your use case, for example by providing a sample JSON that the model needs to adhere.
  3. Conversational UI: there are snippets and building blocks available to implement a chat conversation. 

I hope that helps you to get inspired and build your chat bot in Mendix.

 

Best regards

Liam

answered
-1

Build a Chatbot in Mendix 10.21 Using ChatGPT and PostgreSQL

Objective

  • Let users ask questions in natural language (e.g., “Show mobiles under 20000”)

  • Use ChatGPT to convert input to structured data (e.g., category = mobile, price < 20000)

  • Use structured data to search PostgreSQL

  • Display results in Mendix

Tools Required

  • Mendix 10.21

  • OpenAI Connector v5.2.0Link: https://marketplace.mendix.com/link/component/120144

  • PostgreSQL Database

  • (Optional) External Database ConnectorLink: https://marketplace.mendix.com/link/component/118664

Implementation Steps

1. UI Setup

  • Add a text input field and a send button

  • On button click, trigger a microflow

2. Store User Input

  • Create an entity UserQuery with fields:

    • UserInput (String)

    • StructuredCategory (String)

    • StructuredPriceLimit (Decimal)

3. Call ChatGPT

  • Use CallOpenAIChatCompletion from OpenAI Connector

  • Provide prompt to extract structured filtersExample prompt:

    Convert this question into JSON format: "Show mobiles under 20000" Expected Output: { "category": "mobile", "price_limit": 20000 }

4. Parse ChatGPT Response

  • Create a JSON structure based on the expected output

  • Use Import Mapping to convert JSON to Mendix object

  • Store values in StructuredCategory, StructuredPriceLimit

5. Query PostgreSQL

  • Option A: If data is in Mendix, use XPath

  • Option B: If using PostgreSQL directly, use OQL or SQL via External Database Connector

6. Display Results

  • Use a ListView or DataGrid to show filtered results

  • Bind it to a microflow or data source returning the query result

answered