Supported User journeys

This section describes the user journeys supported by Slang Retail Assistant

Now that you have the basic idea of how to configure and integrate the Assistants into your app, let's learn more about the User Journeys, App States, and Conditions that Slang supports

Slang Retail Assistant supports the following user journeys -

  • Search

  • Navigation

  • Order Management

Let's go into details of each of them

Search User Journey

Whenever the Assistant detects that the user is searching for items in the app, it will try to break down the search request into its components and invoke the callback associated with the search user journey. The callback looks like this:

Android Native
React Native
Web
Android Native
SearchUserJourney.AppState onSearch(SearchInfo searchInfo, SearchUserJourney userJourney);
React Native
onSearch: async (searchInfo, searchUserJourney)
Web

When this callback is invoked, the app is expected to -

  • Consume the results of the details of the search request via the "searchInfo" parameter.

  • Fire the search request as the app would normally do

  • Based on how the search result came back, set appropriate conditions in the Assistant

  • Finally, return the AppState that the app transitioned to.

For example, for a given onSearch callback invocation, if the search completes successfully and the app transitions to a screen showing search results, the app would set the Condition to SUCCESS and return AppState as SEARCH_RESULTS, as shown below:

Android Native
React Native
Web
Android Native
public SearchUserJourney.AppState onSearch(SearchInfo searchInfo, SearchUserJourney searchJourney) {
String searchItem = searchInfo.getItem().getDescription();
// Launch SearchResultsActivity using "searchItem"
// ...
userJourney.setSearchSuccess();
return SearchUserJourney.AppState.SEARCH_RESULTS;
}
React Native
onSearch: async (searchInfo, searchUserJourney) => {
var searchItem = searchInfo.item.description;
// Launch SearchResultsActivity using "searchItem"
// ...
searchUserJourney.setSearchSuccess();
return SearchUserJourney.AppState.SEARCH_RESULTS;
},
Web

The following are some examples of commands that could trigger this journey

  • "Onions"

  • "Show me onions"

  • "3 kgs organic onions"

  • "Looking for fresho organic onions"

  • "Searching for Maggi Instant noodles in grocery"

  • "2 rs head and shoulders shampoo"

SearchInfo Parameter

The SearchInfo parameter contains the breakdown of the original search request. It will have the following fields -

Android Native
React Native
Web
Android Native
Class SearchInfo {
public Item getItem();
public List<FilterInfo> getFilters();
public SortingInfo getSorting();
}
Class Item {
public String getId(); // The ID of the item if set by the app or if Slang
// was trained with it
public String getCategory(); // The category that the user specified,
// eg "pharmacy" or "grocery"
public String getBrand(); // The brand name identified by Slang from what the
// user spoke
public String getProductType(); // The product type if any as identified by Slang
public String[] getVariants(); // The variants (like "organic") if any
public String getDescrption(); // The helper method to get back a fully
// constructed search string from what the
// user spoke
public Quantity getQuantity(); // The quantity if any is spoken by the user
public Size getSize(); // The size if any is spoken by the user
public Price getPrice(); // The price value if any spoken by the user
}
React Native
// When the user searches for something like
// 3 fresho organic onions 2 rupees 3kg in grocery
// This is how the SearchInfo parameter would be populated
{
"filterInfoList": [],
"item": {
"brand": "fresho organic",
"category": "grocery",
"description": "fresho organic onions",
"id": null,
"price": {
"currency": "INR",
"maxAmount": 3,
"minAmount": 3
},
"productType": null,
"quantity": {
"amount": 2,
"unit": "UNKNOWN"
},
"size": {},
"variants": [
"onions"
]
},
"sortingInfo": {}
}
Web

So when the user says "Searching for fresho organic onions in grocery", the following will be set in the Item object

  • id = null

  • category = null

  • quantity = null

  • size = null

  • price = null

  • brand = "fresho"

  • product type = "onion"

  • variants = "organic"

  • description = "fresho organic onion"

Supported AppStates

The following App States are supported. This will get extended further constantly with newer updates.

  • SEARCH_RESULTS - When the App has performed a search using the SearchInfo parameter

  • UNSUPPORTED - When the App is not ready to handle search yet, it can return this. The Assistant will speak out an appropriate prompt back to the user.

There is a special app state called WAITING that is common across all user journeys that can be used to doing async operations inside the callback. Refer to the Async Handling section under Advanced Concepts for details of async communication between the app and the Assistant.

Supported AppState Conditions

The following App State Conditions are supported for each of the App States supported by the Assistant

App State

App State Condition

Description

SEARCH_RESULTS

  • setSearchSuccess

  • setSearchItemNotFound

  • setSearchItemOutOfStock

  • setSearchItemOutOfStock

  • setSearchFailure

  • The search was successful

  • The item being searched could not be found

  • The item being searched is out of stock

  • The user did not specify any item

  • There was a failure while searching

Assistant Prompts

Now based on the App State and the Condition that was set, the Assistant will speak out an appropriate message to the user. You can look at the Console to find out the default set of prompts that the Assistant will speak out and you can also customize it to your needs. Refer to the Customizing the Assistant section for details.

Order Management User Journey

If the Assistant detects that the user is trying to view or cancel their orders, it will invoke the callback associated with the order management user journey. The callback looks like this:

Android Native
React Native
Web
Android Native
OrderManagementUserJourney.AppState onOrderManagement(OrderInfo orderInfo, OrderManagementUserJourney userJourney);
React Native
onOrderManagement: async (orderInfo, orderMangementUserJourney)
Web

When this callback is invoked, the app is expected to -

  • Use the OrderInfo parameter to check if the user is interested to view or cancel their past orders

  • Open the corresponding order page using the index field in the OrderInfo parameter

  • Based on the condition of the specific order, set appropriate conditions in the Assistant

  • Finally, return the AppState that the app transitioned to.

For example, for a given onOrderManagement callback invocation, if the user asked for viewing a specific order, and if that order did not exist, the app would set the Condition to OrderNotFound and return AppState as VIEW, as shown below:

Android Native
React Native
Web
Android Native
public OrderManagementUserJourney.AppState onOrderManagement(OrderInfo orderInfo, OrderManagementUserJourney userJourney) {
int orderIndex = orderInfo.getOrderIndex();
if (!checkOrder(orderIndex)) { // Order does not exist
userJourney.setViewOrderNotFound(orderIndex);
} else {
userJourney.setViewSuccess();
}
return OrderManagementUserJourney.AppState.VIEW_ORDER;
}
React Native
onOrderManagement: async (orderInfo, orderMangementUserJourney) => {
var orderIndex = orderInfo.orderIndex;
if (!checkOrder(orderIndex)) { // Order does not exist
userJourney.setViewOrderNotFound(orderIndex);
} else {
userJourney.setViewSuccess();
}
return OrderManagementUserJourney.AppState.VIEW_ORDER;
},
Web

Sample Utterances that could trigger Order Management

The following are some examples of commands that could trigger this journey

  • "show my orders"

  • "where is my last order"

  • "cancel my first order"

OrderInfo Parameter

The OrderInfo parameter contains the breakdown of the original order request. It will have the following fields -

Android Native
React Native
Web
Android Native
Class OrderInfo {
int getOrderIndex(); // The index of the order
OrderAction getOrderAction();
enum OrderAction {
VIEW,
CANCEL
}
}
React Native
Web

So when the user speaks "show my last order",

  • Index = -1

  • OrderAction = VIEW

When the user speaks "cancel my order"

  • Index = 0

  • OrderAction = CANCEL

index can take the following values .-

  • -1 = to indicate last order ("cancel my last order")

  • 0 = when no explicit order is mentioned or when the user says "all" (show my order or show all my orders" or "where is my order")

  • 1...n = The index as mentioned by the user ("show my first order")

Supported AppStates

The following App States are supported. This will get extended further constantly with newer updates.

  • VIEW_ORER - When the app is able to handle the order request

  • UNSUPPORTED - When the App is not ready to handle orders yet, it can return this. The Assistant will speak out an appropriate prompt back to the user.

There is a special app state called WAITING that is common across all user journeys that can be used to doing async operations inside the callback. Refer to the Async Handling section in the Advanced Concepts page for details of async communication between the app and the Assistant.

Supported AppState Conditions

The following App State Conditions are supported for each of the App States supported by the Assistant

App State

App State Condition

Description

VIEW_ORDER

  • setViewSuccess

  • setViewEmptyOrders

  • setViewOrderNotFound

  • setViewFailure

  • The order could be shown successfully

  • There are no orders to show

  • The specified order was not found

  • There was a failure while showing orders

Assistant Prompts

Now based on the App State and the Condition that was set, the Assistant will speak out an appropriate message to the user. You can look at the Console to find out the default set of prompts that the Assistant will speak out and you can also customize it to your needs. Refer to the Customizing the Assistant section for details.

Navigation User Journey

If the Assistant detects that the user is trying to navigate to various parts of the app, it will invoke the callback associated with the Navigation user journey. The callback looks like this:

Android Native
React Native
Web
Android Native
NavigationUserJourney.AppState onNavigation(NavigationInfo navigationInfo, NavigationUserJourney userJourney);
React Native
onNavigation: async (navigationInfo, navigationUserJourney)
Web

When this callback is invoked, the app is expected to -

  • Use the NavigationInfo parameter to check the target page the user is interested to go to

  • Open the corresponding page using the target field

  • Based on the condition of the specific navigation, set appropriate conditions in the Assistant

  • Finally, return the AppState that the app transitioned to.

For example, for a given onNavgiation callback invocation, if the user asked for viewing the cart, and if the app is able to navigate to that page successfully, it sets the SUCCESS condition and returns the NAVIGATION app state.

Android Native
React Native
Web
Android Native
public NavigationUserJourney.AppState onNavigation(NavigationInfo navigationInfo, NavigationUserJourney userJourney) {
switch (navigationInfo.getTarget()) {
case "cart":
// Goto cart
// ...
userJourney.setNavigationSuccess();
return NavigationUserJourney.AppState.NAVIGATION;
// ...
}
}
React Native
onNavigation: async (navigationInfo, navigationUserJourney) => {
switch (navigationInfo.getTarget()) {
case "cart":
// Goto cart
// ...
userJourney.setNavigationSuccess();
return NavigationUserJourney.AppState.NAVIGATION;
// ...
}
},
Web

Sample Utterances that could trigger Navigation

The following are some examples of commands that could trigger this journey

  • "goto my cart"

  • "pharmacy"

  • "take me home"

The NavigationInfo parameter contains the breakdown of the original navigation request. It will have the following fields -

Android Native
React Native
Web
Android Native
Class NavigationInfo {
String getTarget(); //Terget to which app has been asked to navigate
}
// Possible target values
"back", "home", "pharmacy", "grocery", "basket", "order"
React Native
Web

Supported AppStates

The following App States are supported. This will get extended further constantly with newer updates.

  • NAVIGATION - When the app is able to handle the navigation request

  • UNSUPPORTED - When the App is not ready to handle navigation yet, it can return this. The Assistant will speak out an appropriate prompt back to the user.

There is a special app state called WAITING that is common across all user journeys that can be used to doing async operations inside the callback. Refer to the Advanced section for details of async communication between the app and the Assistant.

Supported AppState Conditions

The following App State Conditions are supported for each of the App States supported by the Assistant

App State

App State Condition

Description

NAVIGATION

  • setNavigationSuccess

  • setNavigationInvalid

  • setNavigationFailure

  • The navigation was successful

  • The navigation target is not valid

  • There was a failure while navigating

Assistant Prompts

Now based on the App State and the Condition that was set, the Assistant will speak out an appropriate message to the user. You can look at the Console to find out the default set of prompts that the Assistant will speak out and you can also customize it to your needs. Refer to the Customizing the Assistant section for details.