Last active
March 12, 2021 06:44
-
-
Save FredrikOseberg/161bbcc7220ded5de7a1fce834d7fe99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MessageParser { | |
constructor(actionProvider, state) { | |
this.actionProvider = actionProvider; | |
// State represents the chatbot state and is passed | |
// in at initalization. You can use it to read chatbot state | |
// inside the messageParser | |
this.state = state | |
} | |
parse = (message) => { | |
const lowerCase = message.toLowerCase(); | |
if ( | |
lowerCase.includes("messageparser") || | |
lowerCase.includes("parse") || | |
lowerCase.includes("parser") || | |
lowerCase.includes("message parser") | |
) { | |
return this.actionProvider.handleMessageParser(); | |
} | |
return this.actionProvider.handleDefault(); | |
}; | |
} | |
export default MessageParser; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if we have one string inputs from the user in the text field, but it can be for search flight or for search airport, how will we distinguish and parse and call the API according? Also, can we read the input text field and previously selected options together and check?
Thank you