There's not much fun in only being able to ask Siri if your server is up and running or what your location is. In order to extend the functionality of siriproxy, the best way to do it is by creating your own plugin. The current documentation is somewhat limited when it comes to details, so I've tried to make each step more clear.

Here is how you create a plugin for siriproxy.


If you haven't done so already, check out my guide to installing siriproxy on a Raspberry Pi.

I know that the plugin feature of SiriProxy is fairly new, so I would recommend that you check the official SiriProxy Plugin Developer Guide to see if they've changed the procedure.

Copy the exsample plugin

Essentially you'll be creating a ruby gem, which means there's a bunch of boilerplate code. So the quickest way to get started is by copying the existing example plugin and working off that.

$ cd ~/SiriProxy/plugins
$ cp -r siriproxy-example siriproxy-myplugin
$ cd siriproxy-myplugin

Note: The way siriproxy loads plugins requires that the name of the plugin starts with siriproxy-

Rename and edit the gemspec

Make the needed changes to the names, description etc. in the gemspec.. this should be straightforward.

$ mv siriproxy-example.gemspec siriproxy-myplugin.gemspec
$ vi siriproxy-myplugin.gemspec

Note: If your plugin has any dependencies, you need to add them at the bottom of the gemspec as these will be loaded at runtime.

s.add_runtime_dependency "wiringpi"

Rename and edit siriproxy-example.rb

$ cd lib
$ mv siriproxy-example.rb siriproxy-myplugin.rb
$ vi siriproxy-myplugin.rb

Note: Pay attention to the class name. In this case it should be SiriProxy::Plugin::MyPlugin. We're going to use the name in the proxy config.

The example file is full of ways to use the interface, so I won't go into detail on how to actually write the actual plugin. Once you have siriproxy loading the plugin correctly, it will be easy for you to change and test the functionality.

For now just add the following method to the class:

listen_for /test my addition/i do
  say "Your plug-in is loaded and working"

Siriproxy loads the plugin at runtime, and the siriproxy gem we're running is installed with rvm. We'll be giving siriproxy a relative path to the plugin, so we need to add a symbolic link to the plugin at the install location of the siriproxy gem.

$ cd [email protected]/gems/siriproxy-0.4.0/plugins
$ ln -s /root/SiriProxy/plugins siriproxy-myplugin

Note: Be sure to tab your way into the gem folder since it varies depending on your ruby version and gem version.

Add the plugin to siriproxy config

$ vi ~/.siriproxy/config.yml

And add the lines

- name: 'MyPlugin'
      path: './plugins/siriproxy-myplugin'

As mentioned, the naming needs to match both the folder name and the class name in siriproxy-myplugin.rb

Run bundle

The last thing we need to do is to run bundle

$ cd ~/SiriProxy
$ bundle
# ...
# Your bundle is complete!

Start the server and test your plugin

$ siriproxy server
# [Info - Server] Starting SiriProxy on
# [Info - Server] SiriProxy up and running.

You should be able to tell Siri "Test my addition" and get the expected answer.