How to Build a Chatbot in Mendix That Queries My App’s Database as a Knowledge Base

0
Hi everyone, I’m looking for guidance on implementing a chatbot in my Mendix app that can act as an intelligent interface over my existing application database. Specifically, I want users (e.g., company admins) to be able to enter free-text queries like: “Show me everything about John Doe” “What is Jane Smith’s current department?” “Give me the employment history for employee ID 12345” …and have the chatbot respond by fetching and returning the relevant data from my Mendix domain model (employee records, department assignments, employment history, etc.). Essentially, I want the app’s database to serve as the chatbot’s knowledge base, so that it can intelligently retrieve and present the data based on the user’s natural-language request. Has anyone done something similar in Mendix? I would really appreciate any advice on: How to architect this in Mendix (microflows, APIs, NPEs?) Any recommended AI/NLP services or integrations (OpenAI, Azure, Google, etc.) Best practices for secure access to sensitive data via chatbot How to handle queries that might need to join multiple entities i have already installed mendix 10.21 and openai connector
asked
2 answers
0

Hi Pranav,

 

that is indeed possible and we have a lot of examples that demonstrate that pattern (most often used via function/tool calling).

 

Check out the following resources:

 

  1. Docs Integrate Function Calling into Your Mendix App
  2. GenAI Showcase App (at lot of example around GenAI)
  3. Agent Builder Starter App (ticket support assistant that connects Mendix entities with a model using function calling)

 

I hope that helps!

 

Best regards,

Liam

answered
-1

A. Mendix Setup

  • Create Non-Persistable Entities (NPEs): UserQuery, ChatResponse

  • Design a page with:

    • Input field for the user's natural language query

    • Button to trigger the microflow

    • View to show chatbot response

  • Use a microflow to process the query

B. OpenAI Integration

  • Install OpenAI Connector from Mendix Marketplacehttps://marketplace.mendix.com/link/component/209241

  • Use system prompt to request structured JSON from the model

  • Send user query to OpenAI using the connector

  • Parse the response using StringToJSON or JavaScript action

C. Fetching Data from Mendix

  • Create sub-microflows for different intents:

    • getEmployeeProfile

    • getCurrentDepartment

    • getEmploymentHistory

  • Use XPath or associations to retrieve related data

  • Use dynamic logic in the main microflow to route based on intent

D. Security Considerations

  • Apply role-based access to entities and microflows

  • Sanitize user inputs to prevent prompt injection

  • Log all chatbot interactions for auditing

E. Optional Enhancements

  • Use Azure OpenAI if enterprise security or compliance is required

  • Use vector search for unstructured data like resumes or comments

  • Add browser-based voice-to-text input for user convenience

F. Reference Links

answered