You can build your logic in mendix.
You can have a Separate master entity for Bot Responses and String attribute to store the key words and another entity for chat associated with account entity.
When ever a New chat object is being sent , do a retrieve from the Bot Master (Fetch the response) matching the key word and create a New object in Chat entity, this way for each of the User input retrieve response from bot Master object and create New Chat object( With all possible responses) and show it to the user.
Hope it helps!!!
In Mendix you can build all the logic you want (in combination with Java), but the question is should you build it from scratch in Mendix or use third party solution(s) which are probably more complete like Dialogflow, Wit.AI, Intercom etc. Assuming you considered that extensively, you can set up like this;
1 – build a chat mechanism to send/receive messages, you can use a microflow timer to retrieve messages and show it in a custom list view, mimicing a chat conversation. be carefull with performance costs. or use a third party solution like
2 – build logic to support dialogs for chat with intents,entities, patterns, for more info you can have a look at; https://teamtreehouse.com/library/intents-entities-and-dialogs
From experience I can advise you the quickest, cheapest, good solution; wit.ai less complicated, easy to integrate and free.