Retail Assistant Guide
Steps to integrate the retail assistant into your app
Slang’s Web Retail Assistant (aka SlangRetailAssistant) is a fully trained voice assistant specialized for Web apps in the Retail domain. By integrating with this assistant, apps can help their users perform the following user journey through voice:
Search for the grocery retail items
The following guide describes the steps that apps need to take in order to integrate with the assistant.
Add the assistant to your project
Depending on your package management system, you can follow the steps under the appropriate tab below to add the SlangRetailAssistant.
This should bring SlangRetailAssistant into the scope of your application, and you can refer to it.
Integration Details
First define your actionListener
onSearch action handler is called once the assistant collects the details of the search from the user. It passes SearchInfo and AssistantSession objects as parameters and the handler is expected to return SearchResult once taking necessary action.
All these functions can be async, in which case either return a promise or use async/await.
SearchInfo: Contains the details about the search made by the user. RetailItem is the key property of this object that contains the details about the item being searched. RetailItem contains the following fields to get granular details of the item being searched.
Session and return values
SearchResult: The SearchStatus value that you return from the onSearch()
API allows you to have fine-grained control over the behavior of the SlangAssistant in the following ways:
UNSUPPORTED
- Indicates that the app is not handling this particular user journey. Slang assistant will speak an appropriate message to the user and exit.SEARCH_SUCCESS
- Indicates that the search was successful. Slang assistant will speak an appropriate success message to the user and exit.SEARCH_FAILURE
- Indicates that the search was not successful. Optionally, the reason for the failure can be set in the AssistantSession object. Slang assistant will speak an appropriate failure message to the user and exit. Supported failure reasons are:ITEM_NOT_FOUND - Indicates that the requested item is not sold on the app.
ITEM_OUT_OF_STOCK - Indicates that the requested item is not in stock currently.
AssistantSession: This is the assistant's session object for the current interaction with the user. This should be used in conjunction with the search result. Mainly to communicate failure reasons Below are the APIs to be used for these purposes.
Set the action listener
Then initialize slang assistant
Showing/Hiding the assistant UI (mandatory)
Starting the conversation automatically (optional).
By default, the Slang assistant will prompt the user to speak the item to search on the user clicking the trigger. However, if the app would like to prompt users automatically when landed on a specific page, it could do so by using the below API.
Last updated