ChatterBot
ChatterBot copied to clipboard
Dialogs
Is this possible with chatterbot?

I mean we can find the terms but what would be the approach to look up found keywords in Database using closest match?
Any one can shed some light?
If the only answer is 'you got it' or 'no there is not a flight', then I would say 'yes', with some modifications. It also depends on how your database is set. For example, you can set the chatbot to search keywords like "from", "to" and "$".
You can write a logic adapter with a regex that matches the phrase and extract the parameters (and then contact a "flight api" for searching a flight); an example could be the UnitConversion LogicAdapter of chatterbox: https://github.com/gunthercox/ChatterBot/blob/master/chatterbot/logic/unit_conversion.py
It is not difficult at all, for my bot I'm writing adapters using this technique for various actions
@dakk, thank u for the info. So if city is not valid, I send it as 0 confidence? How the bot will make it say to enter a valid city? Not just city, what the name of flight is incorrect too. How can I tell the bot to ask user to enter valid city and flight name.
Also, can I use chatterbot.logic.BestMatch to find the city in database to make sure city exists and is valid. If so, it passes to the next LogicAdapter that will do the parsing and API check.
I guess once I know this I can start coding :)
@kodeine I did like this:
- in the can_process, I check only if the regexp match: if yes, return true
- in process, I always return 1.0 confidence; if a parameter is not valid, I return a responde that prompt the user the problem
@dakk awesome, clears the whole thing in my mind. One last question.
So if a parameter is not valid and a response is sent, please enter a valid city.
The next sentence user will write will be New York, will i have access to previous statements and the params i found in can_process? Because i need a way to know the last question i asked was what city and New York is in that response and then merge them with already collected data to be able to send the all collected params to flights API. I'm trying to put together the case in my head so i can start coding. Thanks a lot for your input.
@kodeine This is a tricky question, I'm not sure about that; you can follow a flow like this:
- When the logicadapter replies "Please enter a valid city", the logicadapter caches the malformed request with the invalid city, with a flag that indicates the user will send a city in the next sentence
- When the user reply with a city, and the logicadapter.can_process sees that there is the "flag" enabled, it returns true
- The logic adapter will receive the statement containing the city; it gets the previous malformed request, inject the correct city, and executes the action
That's only an idea, but could work