Are there some open source alternatives to what Wit.ai does, i.e. mapping voice/text queries to actions by defining recognition patterns?
(Wit.ai has an open API, but source code is closed, making it inappropriate for education purposes.)
There are no open source alternatives. Kaldi is probably the best open source speech recognition system, but it is extremely non-trivial to set up (I still haven't managed it actually). I've used Sphinx in the past but it is very low quality (think 2000's-era speech recognition - i.e. before it was any good).
As for the NLP side of things, what I call "intent recognition", I haven't looked into it that much, but Stanford's CoreNLP may be a good place to start. Again I expect it to be extremely non-trivial.
There are two similar closed-source alternatives - Nuance Mix, and Houndify, but as of now (Feb, 2016), they are both effectively closed betas (Houndify doesn't let you create custom commands yet, and Nuance hasn't opened their HTTP API, though you can access it via Android or iOS).