Creating custom Siri Behaviour

Post to Twitter Post to Delicious Post to Facebook

Now that we’ve got Siri up and running on the RPi I want to start integarting it.  Unfortunately I’m waiting for a GPIO connector so I thought I’d play with Siri itself to get a feel for the SiriProxy functionality.

Before running this you should have SiriProxy running, the below posts will explain how to do that:

Customising the Siri Commands

SiriProxy has the ability to create plugins.  To save time however I am just going to edit teh SiriProxy config file to add some custom Siri behaviour.

  1. Log into a terminal on the RPi running SiriProxy
  2. Ensure SiriProxy is not running
  3. Enter the following command
    sudo nano /root/SiriProxy/plugins/siriproxy-example/lib/siriproxy-example.rb
  4. This opens the code file that is used top customise Siri commands.  This code is written in Ruby as such it is fairly easy to understand, take some time to look at the example commands.
  5. The example we will create will take a question “Shall we got to the Bluebell for a drink”, generate a random number and then return an answer based upon the random number generated.
  6. Paste the below code into the file
    #Siri 8 Ball
     listen_for /shall we go to the Bluebell for a drink/i do
     #create a random number to generate and answer from, between 0 and 4
     ans = rand(4)
     case ans
     when 0
     say "Of course you should go for a drink, why wouldn't you?"
     request_completed
     when 1
     say "Don't you think you've drank enough? Maybe you should just stay in"
     request_completed
     when 2
     say "One drink wouldn't hurt anyone, but make sure it's only 1"
     request_completed
     when 3
     say "What are you doing here?! Why haven't you got your coat on already!"
     request_completed
     else
     say "Sorry I'm unable to decide, it's too difficult"
     request_completed
     end
    
    end
    
    
  7. Now press Ctrl+x, then y to save and exit
  8. To include the commands in SiriProxy we must first bundle them together, to do this run the following:
    siriproxy bundle

    Note you must be in the SiriProxy directory

  9. Now you can start the SiriProxy, using
    rvmsudo siriproxy server

    If you have followed by blog entries you will need to be logged in as root and in the SiriProxy directory when you run this.

  10. Now you can test the new commands:

    http://www.youtube.com/watch?v=mc1Pv2-rmPM&feature=youtu.be

  11. You can change and customise these plans as you like, in a later post we’ll look at integrating Siri with the GPIO pins.

Post to Twitter Post to Delicious Post to Facebook

2 thoughts on “Creating custom Siri Behaviour

  1. Thanks – this is the best guide to getting Siri Proxy up and running that’s out there. Look forward to the next installments.

    One note – steps 6 and 7 in the previous post have formatting issues that could throw people off. They look like this (at least to me, in Chrome on Mac):

    echo ‘[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function’ >> ~/.bash_profile

    Those steps appear in other people’s posts, but it would be great to clear up those minor stumbling blocks for folks that are seeing this for the first time.

    Nice work all around.

    • Thanks for the comment Dave. I’ve correct those errors (and moved the site to a more personal domain name, I thought it was about time I logged these things as myself!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>