I'm creating some kind of a "personal assistant" application which is basically a web service that receives a message and then does something according to it.
For example I send "what time is it?" and I get the current time as answer. Other examples:
- "tell me a joke" -> queries and sends some joke from an public api
- "I have to [X] -> sets [X] to todo list
- "What do I have to do?" -> sends todo list
- "Start my pc" -> Starts PC via Wake On Lan
or what ever else comes to my mind.
My first prototype just uses an if else statment which looks something like
if message.contains("foo"): # do foo stuff elif message.contains("bar"): # do bar stuff
Of course this will be a total mess after adding several commands so I'm thinking about what would be a good concept to structure such a huge conditional statement.
(I'm using Python with the web.py framework)
One idea is to use some list / map to create a mapping between key words and associated functions and split functionality in different classes (like a todo list module and so on).
There are applications like WolframAlpha or Siri which have just a single input method but several hundred or thousand different functions in the brackground. Of course those are on a totally different level but in general, how do you create a nice and clean branching from a single input to a big number of different functions?