Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

Show List #92

Open
sbaumgarten opened this issue Nov 30, 2011 · 10 comments
Open

Show List #92

sbaumgarten opened this issue Nov 30, 2011 · 10 comments

Comments

@sbaumgarten
Copy link

Hey,
How can I show a list, like when you ask it what good restaurants are near you. I've tried to figure it out by logging all the data Guzzoni sends but I haven't found much.

Thanks

@netpro2k
Copy link
Collaborator

Siri is capable of displaying 2 types of lists. 1. option lists (like it shows when it wants you t select a phone number for a contact) and 2. location lists (like when doing a restaurant search).

We currently dont have API's exposed for either of these but we do plan to add them

@sbaumgarten
Copy link
Author

Is there any way you can send me a beta copy of them?

@netpro2k
Copy link
Collaborator

netpro2k commented Dec 1, 2011

All code we write is public on github. The dev branch will always represent the latest code. As of now, nobody has started work on selection lists.

@sbaumgarten
Copy link
Author

I just got it working on my computer. Could I contribute to the repo.

@netpro2k
Copy link
Collaborator

netpro2k commented Dec 1, 2011

we would like to add it as part of the "ask" method like:

ask "Which one?", options: ["Option 1", "Option 2"]

Would love to see your code, and if you have implemented it like the above, would love a pull request

@davaxi
Copy link

davaxi commented Dec 2, 2011

sbaumgarten, your object list is perfect. However I find it hard to understand how to retrieve the value selected. Could you help me with an example that would be perfect.

@netpro2k
Copy link
Collaborator

netpro2k commented Dec 2, 2011

In the planned implementation it will be retrieved like so:

chosenOption = ask "Which one?", options: ["Option 1", "Option 2"]

@sbaumgarten
Copy link
Author

@netpro2k I'm currently looking at the cora source to try and figure out how I would add it to the ask method. @davaxi and @netpro2k Currently I got it to work by adding the following code to siri_objects.rb:

class SiriDisambiguationList < SiriObject
 def initialize(speakableSelectionResponse="OK...", listenAfterSpeaking=true, speakableFinalDelimiter=", or ", speakableDelimiter=", ", items=[])
 super("DisambiguationList", "com.apple.ace.assistant")
 self.speakableSelectionResponse = speakableSelectionResponse
 self.listenAfterSpeaking = listenAfterSpeaking
 self.speakableFinalDelimiter = speakableFinalDelimiter
 self.speakableDelimiter = speakableDelimiter
 self.items = items
 end
 end
 add_property_to_class(SiriDisambiguationList, :speakableSelectionResponse)
 add_property_to_class(SiriDisambiguationList, :listenAfterSpeaking)
 add_property_to_class(SiriDisambiguationList, :speakableFinalDelimiter)
 add_property_to_class(SiriDisambiguationList, :speakableDelimiter)
 add_property_to_class(SiriDisambiguationList, :items)

 class SiriListItem < SiriObject
   def initialize(title="", speakableText="", commands=[])
     super("ListItem", "com.apple.ace.assistant")
     self.title = title
     self.speakableText = speakableText
     self.commands = commands
   end
 end
 add_property_to_class(SiriListItem, :title)
 add_property_to_class(SiriListItem, :speakableText)
 add_property_to_class(SiriListItem, :commands)

In the plugin I did

 listen_for /homework/i do
     add_views = SiriAddViews.new
     add_views.make_root(last_ref_id)
     disambiguation_list = SiriDisambiguationList.new
     disambiguation_list.items << SiriListItem.new("Math", "Math", [
     {
    "class"   =>"AddViews",
    "properties"   =>   {
       "temporary"        =>false,
       "dialogPhase"      =>"Summary",
       "scrollToTop"      =>false,
       "views"     =>      [
       {
        "class"=>"AssistantUtteranceView", 
        "properties"=> {
        "text"=>"For Math you have Math Homework #8 due tomorrow.", 
        "dialogIdentifier"=>"Misc#ident", 
        }, 
        "group"=>"com.apple.ace.assistant"
       }
       ]
       }, 
       "group"=>"com.apple.ace.assistant"
       }
       ]
       )
     disambiguation_list.items << SiriListItem.new("English", "English", [
     {
    "class"   =>"AddViews",
    "properties"   =>   {
       "temporary"        =>false,
       "dialogPhase"      =>"Summary",
       "scrollToTop"      =>false,
       "views"     =>      [
       {
        "class"=>"AssistantUtteranceView", 
         "properties"=> {
        "text"=>"For English you have a Journal on today's in class discussion due tomorrow.", 
        "dialogIdentifier"=>"Misc#ident", 
        }, 
        "group"=>"com.apple.ace.assistant"
       }
       ]
       }, 
       "group"=>"com.apple.ace.assistant"
       }
       ]
       )

     disambiguation_list.items << SiriListItem.new("Social Sciences", "Social Sciences", [
     {
    "class"   =>"AddViews",
    "properties"   =>   {
       "temporary"        =>false,
       "dialogPhase"      =>"Summary",
       "scrollToTop"      =>false,
       "views"     =>      [
       {
        "class"=>"AssistantUtteranceView", 
        "properties"=> {
        "text"=>"For Social Sciences you have to work on your final draft and project (if your doing one)!", 
        "dialogIdentifier"=>"Misc#ident", 
        }, 
        "group"=>"com.apple.ace.assistant"
       }
       ]
       }, 
       "group"=>"com.apple.ace.assistant"
       }
       ]
       )

     disambiguation_list.items << SiriListItem.new("Science", "Science", [
     {
    "class"   =>"AddViews",
    "properties"   =>   {
       "temporary"        =>false,
       "dialogPhase"      =>"Summary",
       "scrollToTop"      =>false,
       "views"     =>      [
       {
        "class"=>"AssistantUtteranceView", 
        "properties"=> {
        "text"=>"For Science you have to keep working on your projects!", 
        "speakableText"=>"You have to keep working on your projects!", 
        "dialogIdentifier"=>"Misc#ident", 
        }, 
        "group"=>"com.apple.ace.assistant"
       }
       ]
       }, 
       "group"=>"com.apple.ace.assistant"
       }
       ]
       )
     utterance = SiriAssistantUtteranceView.new("Here are the classes you currently have assignments for. Which one would you like to look at in detail?")

     add_views.views << utterance
     add_views.views << disambiguation_list

     send_object add_views
     set_state :classes_available
     request_completed
   end

@netpro2k
Copy link
Collaborator

netpro2k commented Dec 3, 2011

The code that goes into cora would obviously not deal with the concept of siri option lists, but rather just restrict what options are valid for the ask block. Then in SiriProxy's plugin ask would be overridden to handle displaying of the disambiguation list, but use cora's concept of restricting ask.

@moieza
Copy link

moieza commented Oct 2, 2012

I try to make a plugin :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants