A trakt.tv siri proxy plugin

Hi, Siri

With the siri proxy gem (https://github.com/plamoni/SiriProxy) creating your own fun stuff for iPhone 4s’s Siri is pretty straight forward.

Hi, Trakt

Trakt.tv has an amazing API and I wrote a small wrapper (see lib/trakt.tv) in the project) to fetch a users’s calendar for that night.

How i did it.

First off make sure you read all the documentation on the proxy github page, setting up the DNS server can be tricky if you don’t follow all the steps in the video.

Naming

Naming is very important for the siri proxy so make sure you do it right! The name you set in the siri proxy config should be the classname you extend the plugin from. The name downcased should be the gem name (with siriproxy prepended) It took me a while to figure out and get everything up and running.

Code

def generate_calendar_response(ref_id)
  object = SiriAddViews.new
  object.make_root(ref_id)
  object.views << SiriAssistantUtteranceView.new("Here is your trakt calendar!")

  episodes = Trakt::User::Calendar.new.results.first['episodes']
  episodes.each do |calendar_result|
    object.views << SiriAssistantUtteranceView.new(calendar_result['show']['title'])
  end
  object
end

listen_for /what's on tv tonight/i do
  send_object self.generate_calendar_response(last_ref_id)
  request_completed
end

The listen_for tells the proxy what words to match with the response from apple, the code in the block gets executed when the words match

In the generate_calendar_response i create a new view and add every episode i get from trakt to it. The whole thing gets returned to your iPhone and siri tells you the results :)

The result

The video below shows the result.