Introduction
Yesterday, I wanted to add a feature to Kalliope (my always-on voice controlled personal assistant) : the ability to reminds me of something later on. I have a very selective memory and forget to do a lot of stuff, so when I think about something important, I can gently ask Kalliope to reminds me to do it (:
The main use case
The primary use case (there are other things I’d like to do, see the last paragraph about the todolist) is:
Be able to ask Kalliope to reminds me of something in X minutes.
This translate into these actions:
- A neuron with an order like “remind me in 10 minutes to leave for my appointment”
- Launching a command that will sleep for 10minutes
- After the delay, the command should make kalliope remind me of my appointment
I didn’t / couldn’t do a neuron, seeing the dependencies with languages and a need for an async script (kalliope needs to be able to answer commands in the meantime), a neuron was too complex.
My solution
I ended up creating:
-
A synapse that would just fire a python script that would do all the work.
- The order looks like “remind me {{query}}”.
- The neuron used is the community shell neuron by sending the query to the script.
-
A python script that receive the full query (including time to wait and the “thing” to remember
- The script fire an “at” command to program the wake up
- The command started by “at” will leverage Kalliope API to tell me what to remember.
-
A new neuron to make kalliope say dynamic text.
The repeat neuron
The idea of this neuron is really simple: You send it arguments, and it will send them back as a return value to be used in template or say_template command.
As you can see on the sample brain file, you can do things like “say hello to {{name}}” or what not :).
To install the module, as usual:
kalliope install --git-url https://github.com/bacardi55/kalliope-repeat.git
Then you can configure your brain as usual.
On synapse I created was this one:
- name: "Repeat-via-api"
signals:
- order: "api-repeat-cmd {{ query }}"
neurons:
- repeat:
args:
- query
say_template:
- "{{ query }}"
The idea of this one is just to repeat what is in query when an order is sent that starts with “api-repeat-cmd”. It’s easy enough as I’m sure i will never pronounce a thing like this.
So basically, any API call that will POST an order starting like this will make Kalliope read the text sent.
For example,
curl -i --user admin:secret -H "Content-Type: application/json" -X POST -d '{"order":"api-repeat-cmd Hello sir, how are you ?"}' http://kalliope:5000/order/
This command will make Kalliope say “Hello sir, how are you”.