Scouting Siri Integration for Your Next Third Party iOS App

blog_img
Siri Integration in iOS apps isn’t about automation. It’s about leveraging patterns of behavior to anticipate your customers' needs in time!

I asked: “Hey Siri, do you know Alexa?”

Siri replied: “I offer no resistance to helpful assistants!”

Reminiscing “Hierarchy of Anticipation” by Robert Stephens, one of the co-founders of Assist – The automated assistant platform for message and voice, Siri has been designed to recognize preferences driven by past behavior. This kind of pattern recognition offers opportunities for brands to be proactive with customer engagement. How will it work? In case I’m just ready to place my order, Siri recognizes that I make a particular order, from a specific restaurant, so if in case I have to order my usual, I’ll just wait at my seat and say, “Hey Siri, get me my usual”. Did you catch the simplicity and ease of this command? The beauty lies in the promptness of the digital assistant!

The most prevalent voice assistants for smartphones, available along with iOS and Android devices are Apple’s voice-controlled digital assistant for iOS, Amazon’s Echo (Alexa) and Google Voice assistant for both Android and iOS. Google is said to have taken on Alexa, Siri, and Cortona with its own voice assistant: Google Assistant. All these are quite distinctly different products that ultimately diverge in directionally distinct arcs in both use case and utility. But if you own any or all of these devices, it can be established that there is a great deal of uniqueness and utility with all these.

Are These Voice Assistants Worth Comparing?

Nine years on from Siri, six years on from Alexa and four years on from Google Assistant; Apple, Amazon, and Google have spread their voice assistants far and wide respectively. Although Siri is dependent and specific on Apple devices (its own hardware) but Amazon’s Echo Dot (Alexa) and Google Assistant are not only on Google’s own hardware, but are on through partnerships with other companies that see such voice assistants in a wide range of devices, from fridges to headphones, speakers to cars.

Voice Assistants like Siri vs. Cortona vs. Alexa vs. Google Assistant are quite helpful while doing certain things like setting reminders, composing text messages, taking notes, creating events, setting alarms and making changes to system settings. As real knowledge is to know the extent to one’s ignorance, as soon as users get to know this digital voice or personal assistants more, they tailor their responses individually and that too in your personal/preferred language.

What Can Siri do for You?

Siri can be incredibly useful for those who get used to it. Enabling users to do a wide array of tasks on their iOS devices like creating reminders. Just in case you wish Siri to be a little more useful, ask it to do anything from the list below like asking Siri to place a call, start a FaceTime chat, launch an app, send a message (“Hey Siri, send a Cliq message to Scott”) or (“Video call Scott using Cliq”) , set up a calendar event, find out whether your team won the game, pull up the photos you took the day before, get directions home,  find a restaurant, play some music, set a reminder, etc.

The results might surprise you, but what can be even more surprising is the candidness of the assistant to answer, or at least attempt to answer “human-like” questions in a similar way.

Siri makers brag that it is capable of doing more than one can imagine, even before we ask it! It can help you stay connected without lifting a finger. From making calls to text messages on your behalf to offering proactive suggestions like texting someone that you’re running late for a meeting – allows you to stay updated and in touch effortlessly.

Commands That Siri Listens; there’s Even More Than It Can Do!

Right from reminding you to make calls that matter, Siri eases everyday tasks, is a faster, easier way to do all kinds of useful things. Setting alarms, reminders and previewing calendar is easy without the need to pick up a device. Although it cannot order on user’s behalf at the moment Siri can as well suggest shortcuts based on your routine. Siri can predict too. Based on your routine, it can come up with intelligent suggestions that can ease your routine tasks out.

  • “Hey Siri call baby on speaker”
  • “Read my last message”
  • “Text Tony, I’m on the way exclamation mark”
  •  Don’t know who’s calling? Siri can help
  • “Message Chris, I’ll be there in 30 minutes on WhatsApp”
  • “Facetime Dale”
  • “Hey Siri, wake me up at 5:30 AM tomorrow” (Siri replies, “Ok, alarm set for 5:30 AM tomorrow”)
  • “Split a $15 bill three ways”
  • “Hey Siri, set a timer for 30 minutes”
  • “Remind me to pick up the dry cleaning when I leave for work”
  • Siri can play songs based on your most played songs or preferred playlists. It’s easier as Apple music and Siri work together beautifully. So, you can give it commands like – “Hey Siri, play me something I’d like”
  • Ask it more about the song, “Hey Siri, what song is this?”
  • “Play me some 90’s hip hop”
  • “Play the latest Evergreen Upbeat” from Gaana.com
  • If you want to try it more, Siri suggests the required playlists exactly when you want them.
  • If you are not satiated, Siri has answers to all kinds of questions – How do you say “Thank You” in Mandarin?
  • “How many rupees are 45 euros?”
  • Siri watch face keeps you stay on top of stocks, scores, your schedule, and activity rings, etc.
  • What’s the derivative of Cosine(x)?
  • It can accept some extravagantly humorous queries like
  • “Show my pics from last summer”
  • “Find my Airpods”
  • “Open the presentation that I was working on Yesterday and likewise”

What Happens When Siri Makes Mistakes?

It might be infuriating at times when the digital assistants fail to catch the user command and come out with vague replies. But a user shouldn’t be too quick to dismiss it. These voice assistants like Google Now, Siri and Microsoft’s Cortona can be really useful and time-saving tools for getting things done and finding information. There is a need to invest some time and effort to better understand how smarter these assistants are.

Integrating Siri (Sirikit) into Next Third Party iOS App

Siri in iOS now supports third-party apps which implies that it can now interact with apps like Skype, PayPal, Uber, and some others Siri compatible apps that have chosen to include support for Siri virtual assistant.  In actual practice this allows users to give certain commands to Siri like “send $10 to Mark using PayPal” or “Get me an Uber to airport”. Enabling Siri in third-party apps for iPhone and iPads is easy.

Siri integration requires iOS 10 or later versions along with installing third-party apps to be used. Some manual integration is also required for third-party apps.

As an example of how Siri functions in a normal consulting company app with their managers through a voice messaging system: A user opens Siri and calls out: “Hey Siri, send a Facetime message telling my managers that I need help.” Then the request is sent to the managers.

Selecting Domains

A domain is to be selected based on app tasks. Sirikit programming guide suggests names of few domains like VoIP calling, messaging, Payments, photos, workouts, ride booking, CarPlay and restaurant reservations, etc. As an example, here messaging domain (a type of Apple Siri domain) is being used for Siri app integration. As Siri propagates the user’s actions, when a user requests an action from Siri, it sends the user’s intent along with certain necessary details and additional information to the handler for that intent.

If your iOS application offers “domain service”, like ride-booking (e.g.: Uber), fitness (e.g.: Gold Gym), messaging (e.g.: Facebook, Whatsapp, Skype), payments (e.g.: Paypal), it can integrate with Siri to let the user performs certain actions (better called as intents) in response to spoken commands given by users.

Siri is intelligent enough to handle all the language processing and semantic analysis that is required to turn these spoken requests into instructions that the app can handle.  The iOS app defines the tasks it supports, validates the information it receives and provides information for Siri to present and take action.

WatchOS and iOS apps can adopt the Sirikit framework to allow people to use Siri and Shortcuts to perform app-specific actions on Apple Watch, iPhone, iPad, HomePod and CarPlay. Here is a list of domains that Sirikit supports for iOS and watchOS apps.

sirikit supports

Source: https://developer.apple.com

Sending a message, search a message and assigning attributes to a message are three kinds of intents supported by Siri’s messaging domain.

How to Set-up the Base Environment?

  • A Cocoa Touch framework needs to be set up for the app as you can’t use the code directly from your project. This can be set up by selecting File -> New -> Target. After this, select “Cocoa Touch Framework” as the template to be used for your target.
  • Assign a name to your framework in the next window. E.g.: “Core”
  • Check “Embed in application” field.
  • Add classes to the framework. (These classes essentially define the domain of user requests and send those requests to the backend team.)
  • If the classes are already implemented, they must be moved to “Core”. Classes must be removed from the main target and added manually to the framework target, in order to implement this. “Core” framework can then be imported and classes can be used.

Implement the Intent Handler

Implementing Intent Handler is the primary part of integrating Siri into your iOS app. This can be done by adding the “Intents Extension” target in the iOS app by selecting “File–>New–>Target” and then selecting “Intents Extension.” Enter any name, e.g.: “SiriIntentExtension”

Some system information must be provided within “Info.plist” file of the “SiriIntentExtension” to indicate the intents that the app must react to:

siriintentextension

Above code specifies the supported intents list (which contains only one intent in our case, “INSendMessageIntent”). If there is a need to restrict access to intents for locked devices, you can specify a restricted intents list using the “IntentsRestrictedWhileLocked” key.

The “NSExtensionPrincipalClass” key provides the name of the class in your IntentsExtension that decides which handler is to be used for a given intent. Let’s call this class an “IntentHandler”.

The implementation of the IntentHandler class is pretty simple:

intenthandler

As the above code returns an instance of “MessagesIntentHandler” for any given intent (as we have subscribed to only one intent types). If you need to implement support for different intents, you can verify which intent the handler is to be provided for:

returns an instance of messagesintenthandler

Every process happens within “MessagesIntentHandler” class. Here’s the implementation of this class:

messagesintenthandler

As the handler inherits from “NSObject”, the “INSendMessageIntentHandling” protocol requires the use of “NSObjectProtocol” and it contains one required and four optional functions:

  • First function is: “resolveRecipients(forSendMessage:with:)” to indicate the recipient(s) for a given intent. As the recipient, in this case, is a single entity (the server), all suggested recipients can be accepted so that Siri won’t ask users to resolve the recipient themselves. This works as follows:

resolve recipients

  • The next function is “resolveContent(forSendMessage:with:).” This function allows us to validate the input text. For our application, we simply filter empty requests:

resolve content

A user needs to authorize before accessing the app. For this the “INSendMessageIntentHandling” protocol must contain the following code:

insendmessageintenthandling

The above code checks whether an internet connection is available and whether a user is authorized in the application. “NSUserActivity” is passed to the application when the app is opened. If the validation fails, we return an error and an appropriate status code.

Passing a “failureRequiringAppLaunch,” command to Siri will indicate user to open an app. As soon as the user opens the app, the “userActivity” can be detected and suggest that the user can again try after authorization.

Third most important function suggests Siri work as follows:

siri work

This finally resolves the domain of a user request and sends a wrapped message to the server. “intent.content” contains a text message that is recorded by the user. If this attempt fails, a “.failure” response code is sent to Siri so that it can convey it to the user. There is a need to add “NSSiriUsageDescription” key to your app’s “Info.plist.” The complete implementation of “MessageIntentHandler” can be found on GitHub. 

In The End

In order to develop this kind of extension, these points must be noted:

The domain must be added for both the app and the SiriIntentExtension

According to Apple’s docs, custom dictionary of app-specific and user-specific words must be implemented that can help Siri not be misunderstood.

Usage permission of Siri has to be managed by calling “INPreferences.requestSiriAuthorization”

It is important to specify a localization of the name, like a user, must set their language preferences so that Siri understands when the user gives commands in that particular language. This requires the user to pass a “CFBundleDisplayName” key for any localization with the appropriate value.

Finally, Enable Siri Third-Party App Integration in iOS

  • Open the ‘Settings’ app in iOS
  • Go to the “Siri” section and then choose “App Support”
  • Toggle the switch to the ON position next to each app you wish to enable Siri support for

As the Siri gets turned on, it can be put to use for various tasks.

Some Data Crunchers To Spice Up The Context

  • 85% of the customer interactions will be handled without the need of a human agent by 2020.
  • Voice assistants and automated self-service technologies free up call-center employees from routine tier-1 support requests so they can focus on more complex tasks.
  • If customer service issues are sensed beforehand, it could significantly lower customer abandonment rates.
  • Currently, in a 6-minute service call, almost 75% of the time is devoted to digital assistants that do the manual research with valued customer interaction at a dismal 25%.

Capping

To be able to use Siri in iOS app development more accurately, it is important to define custom vocabulary that people use with your app. Any terms defined by the user are used by Siri to help resolve requests but aren’t guaranteed to be recognized. It can give you race stats for motorsports, quickly look up a password or search for your favorite memories and find answers to food and celebrity questions. Consider defining alternate app names and do not try to impersonate other apps by listing their names as alternate names for your app. Also, provide Siri with example requests so that users can utilize Siri in a most efficient way. Take real-time tips on digital voice assistant integration in iOS apps from our experts. Contact us.

YOU MAY ALSO LIKE
About Author
Neeti Kotia

Neeti Kotia

Neeti got her master's degree in software engineering in 2009 and has been working since for software companies of all sizes as a technical writer. What started as a high school passion has now been converted into a serious profession. She has a special knack of learning from all verticals and imbibing the extracts into her writing. She enjoys learning technical aspects of writing from her tasks where her experience and understanding are most impactful.

MAKE YOUR IDEA REACH ITS GRAND DESTINY

WITH PRO WEB AND MOBILE SOLUTIONS

Looking for a development partner?

Why Konstant

Portfolio

Visit Our Portfolio

Top Mobile Blog Winner

Top 15 Latest Mobile Blogs

Mobile App Blog Winner

SUBSCRIBE TO OUR BLOG

Konstant

Get a perfect quote

We’re eager to work with you. Please share your project goals and contact information. We respond to 97% of messages within 1-2 business day. Really!

Or send us an email at: [email protected]