I'm developing a virtual assistant to manage transactions in a business. I'm using an external service to handle Natural Language and get intents, actions and parameters from my user requests.
The client sends requests as text strings to my application logic and my application logic routes the messages to the NLP or the Business.
When a client needs authentication to make a transaction I show a modal dialog to ask for its credentials. Then I append a tag like
'[XXX]' to the
strings so my entry component can route the message directly to the Business service. I also add the same tag to client responses when I want the
client to trigger a specific behavior. For example:
- Client sends the string
'I wan to log in'to Server.
- Server sees no
[XXX]tag, so it hands the string to the NLP service.
- NLP service answers with the action
'UserLogIn'to the Server.
- Server makes a lookup for the action and sends the string
'[Require_Auth]'to the Client.
- Client sees a
[XXX]tag, so it parses the string, shows a modal, asks for credentials and sends
'[Username]ZZZZZZZZ[Password]ZZZZZZZZ'to the Server.
- Server sees a
[XXX]tag, so It parses the string and hands the parameters to the Bussiness Service.
- Business Service creates a session and hands it to the Server.
- Server bookmarks session and sends the string
'Welcome "username"!'to the Client.
- Client sees no
[XXX]tag, so it displays the string in the window.
This means that the client and the server programs have to parse the messages to look for
'[XXX]' tags to trigger specific behavior.
I consider this solution to be bad, so what would be a better approach to trigger specific behavior via messages between client and server?