Understanding intents

Siri is a powerful, smart, and ever-learning personal assistant that aims to give natural responses to natural speech input. This means that there is often more than one way to say something to Siri. Some users like to be extremely polite when they talk to Siri, saying please and thank you whenever they ask for something. Other users like to be short and to the point; they simply tell Siri what they want and that's it.

This means that Siri has to be really smart about how it interprets language and how it converts the user's requests to actionable items. Not only does Siri take into account the language used; it's also aware of how a user is using Siri. If a user activates Siri by saying Hey, Siri!, Siri will be more vocal and verbose than when a user activates Siri by pressing and holding the home or side buttons because it's more likely if they didn't press the home or side button, that the user is not looking at their device.

To convert a user's spoken requests into actions, Siri uses intents. An intent is a way to describe an action. These intents are supported by app-specific vocabularies; this allows you to make sure that your users can use terms that are familiar to them because they are also used in your app.

Siri does not handle an unlimited amount of intents. All of the intents that Siri can handle belong to a predefined set of domains. If you plan to create a Siri extension for your own app, it must fit into one of the predefined domains that Siri understands—unless you provide a custom intent. Currently, Siri handles the following domains out of the box:

  • Messaging (Send a message to Donny that says Hello, World)
  • Calling (Call my sister)
  • Payments (Transfer 5 euros to Jeff)
  • Workouts (Start an outdoor run)
  • Ride booking (Get me a taxi to the airport)
  • Photo search (Find me photos from Paris)
  • Notes (Create a note that says "Don't forget the dishes")
  • Reminders (Remind me to do the dishes when I get home)
  • Visual codes (Show me my ticket for tonight's concert)

If your app is not in one of these domains, you will need to do a bit more work to integrate your app with Siri, as you will learn in the last section of this chapter. In order to integrate Siri with your app, your app must ask the user permission for it to be used with Siri. It's recommended that you do this when your user first opens your app because this ensures that your app is available to Siri as soon as possible. Make sure that you ask for permission appropriately, though; you don't want to unpleasantly surprise your user with a permission request. You also need to add the Privacy—Siri Usage Description (NSSiriUsageDescription) key to your Info.plist file, and enable the Siri capability in your app's Capabilities tab.

You can only enable the Siri capability for your app if you are a paying member of Apple's Developer Program. Unfortunately, you can't enable or test Siri if you haven't got such a membership.

In order for Siri to work with your app, it's important that a user mentions your app's name to Siri when asking it something related to your app. This is to make sure that apps don't hijack certain words or verbs, which would result in a confusing experience. It doesn't matter exactly how or when the user does this. Siri is all about natural language, and it will even understand if your app name is used as a verb. For example, MyBankApp some money to John Doe would be interpreted as a money transfer action with an app named MyBankApp to a person named John Doe.

If a user would literally ask Siri to perform the preceding action, Siri would not be able to fulfill the request yet. In the case of a money transfer Siri has to know two things:

  1. Who should receive the money?
  2. How much money should be transferred?

These requirements are captured in an intent, and if Siri is missing information, it will ask the user directly for this information in order to collect everything needed to successfully transfer the money.

Now that you know what an intent is and what it's used for, let's see how you can implement an intents extension so Siri knows how to use your app to send messages.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.170.223