Integrating Siri in Existing E-Commerce Apps

Nikola Mladenovic
commercetools tech
Published in
3 min readDec 2, 2019

--

Voice-activated assistants and digital assistants are becoming more and more present in eCommerce industry. In fact, trend watchers estimate that 30% of browsing will be screenless by 2020.

Opportunity for Brands with Existing Apps

In 2018, Apple announced that there were 500 million devices in the world that used Siri voice assistant. That has a huge potential for any brand offering an iOS app for their customers. Being able to quickly reorder items they frequently buy, or add something to a shopping list, without having to use the screen and open the app, provides more convenience for customers, and revenue for brands.

With iOS 12, third party apps got access to some of the Siri capabilities. Apps are now able to use predefined intent categories to allow users to record custom phrases, and use them with Siri to perform frequent tasks. Currently available e-commerce related categories are: order, book, and buy.

Choosing a Task for Siri Integration

When thinking about adding Siri support to an existing iOS app, a good first step is to think which tasks make sense to be integrated with voice commands. Frequently used tasks are a good candidate for voice integration. An e-commerce related example we chose to add to our Sunrise iOS app is reordering items customers need on a regular basis.

The first step is to include the Add to Siri button on an order details page. The customer can pick an order from the order overview screen, and then create a custom shortcut.

Previous order details (on the left), Add to Siri UI with suggested invocation phrase (on the right)

Creating Orders from Siri Intents Extensions

Actions triggered by a customer using Siri (known as intents) are executed in a separate process from the associated iOS app. That means it doesn’t have access to the same sandbox and data. As a result, the process launched to handle the Siri request won’t be able to access customer’s profile, create an order, or even know if the customer is logged in.

In order to solve this issue, the commercetools Swift SDK supports keychain sharing. If it’s turned on for both the main app target, the Siri Intents and Intents UI Extensions, you can easily configure the SDK to use the shared keychain. That way, the extension running the order task will be able to access customer’s tokens, and to communicate with the commercetools API to get previous order details, and create a new one, the same way the main app would.

Considering UI for Siri Intents

When defining custom intents and responses, you’ll notice that user confirmation is mandatory for any of the e-commerce categories. It’s important that a customer is aware of actions their voice commands will make, and a final confirmation before placing an order definitely helps.

To make it easier for customers to understand details like what items are being ordered, how much does it all cost, etc, a good practice is to add another target: Siri Intents UI Extension. The UI Extension can handle one or more intents, and it will show a custom UI on customer’s phone before the action (in this case order) is confirmed, as long as the voice command wasn’t issued using HomePod (which obviously doesn’t have a screen).

An example for Siri Intents UI Extension handling order intents

Conclusion

Voice assistants are definitely getting more spotlight in e-commerce domain. For brands already using the commercetools platform, it’s fairly easy to start offering convenient voice commands like ordering, adding items to a shopping list, checking shipping statuses, and others. Swift SDK offers convenient integration options with Siri Intents and many other iOS app extensions. Feel free to check out the actual implementation details referenced in this post at Sunrise iOS / watchOS GitHub repo. You can also get a beta demo build including Siri reorder integration using this link.

--

--