Search…
Navigation
Details about the Navigation user journey

The onNavigation callback

When the Assistant detects that the user is trying to navigate to various parts of the app, it invokes the callback associated with the Navigation user journey. The callback looks like this:
Android Native
React Native
Web
Android (Deprecated)
1
NavigationAppState onNavigation(NavigationInfo navigationInfo, NavigationUserJourney userJourney);
Copied!
1
onNavigation: async (navigationInfo, navigationUserJourney)
Copied!
1
onNavigation: async (navigationInfo, navigationUserJourney)
Copied!
1
NavigationUserJourney.AppState onNavigation(NavigationInfo navigationInfo, NavigationUserJourney userJourney);
Copied!
When this callback is invoked, the app is expected to:
  1. 1.
    Use the NavigationInfo parameter to examine the target of the user's navigation
  2. 2.
    Open the corresponding page/Activity using the target field
  3. 3.
    Finally, return the AppState and Condition that the app transitioned into.
For example, for a given onNavigation callback invocation, if the user asked for viewing the cart and if the app can navigate to that page successfully, it sets the success condition and returns the NAVIGATION app state.
Android Native
React Native
Web
Android (Deprecated)
1
public NavigationAppState onNavigation(NavigationInfo navigationInfo, NavigationUserJourney userJourney) {
2
switch (navigationInfo.getTarget()) {
3
case "cart":
4
// Go to cart page
5
// ...
6
return NavigationCompleteAppState(SUCCESS);
7
}
8
}
Copied!
1
onNavigation: async (navigationInfo, navigationUserJourney) => {
2
switch (navigationInfo.getTarget()) {
3
case "cart":
4
// Goto cart
5
// ...
6
userJourney.setNavigationSuccess();
7
return NavigationUserJourney.AppState.NAVIGATION;
8
9
// ...
10
}
11
},
Copied!
1
onNavigation: async (navigationInfo, navigationUserJourney) => {
2
switch (navigationInfo.target) {
3
case "cart":
4
// Goto cart
5
// ...
6
navigationUserJourney.setNavigationSuccess();
7
return NavigationUserJourney.AppStates.NAVIGATION;
8
9
// ...
10
}
11
},
Copied!
1
public NavigationUserJourney.AppState onNavigation(NavigationInfo navigationInfo, NavigationUserJourney userJourney) {
2
switch (navigationInfo.getTarget()) {
3
case "cart":
4
// Goto cart
5
// ...
6
userJourney.setNavigationSuccess();
7
return NavigationUserJourney.AppState.NAVIGATION;
8
9
// ...
10
}
11
}
Copied!

Sample Utterances that could trigger Navigation

The following are some examples of commands that could trigger this journey
  • "go to my cart"
  • "pharmacy"
  • "take me home"

NavigationInfo Parameter

The parameterNavigationInfo contains the breakdown of the original navigation request. It has the following structure:
Android Native
React Native
Web
1
Class NavigationInfo {
2
String getTarget(); // Target to which app has been asked to navigate
3
}
4
5
// Possible target values
6
"back", "home", "pharmacy", "grocery", "basket", "order"
Copied!
1
Copied!
1
NavigationInfo : { target: <target> }
2
3
// Possible target values
4
"back", "home", "pharmacy", "grocery", "basket", "order"
Copied!

Supported AppStates

The following AppStates are supported.
  • NAVIGATION_COMPLETE (NavigationCompleteAppState): To be returned when the app handles the navigation request
  • UNSUPPORTED (UnsupportedAppState): To be returned when the app is not ready to handle navigation yet. The Assistant will speak out an appropriate prompt to the user.
The Slang Retail Assistant provides a special AppState 'WAITING' (WaitingAppState) that is common across all UserJourney types for completing asynchronous operations within the callback. Refer to the Asynchronous Action Handling section for details of how to deal with asynchronous operations.

Supported Conditions

The following Conditions are supported for each of the AppStates supported by the Assistant
App State
App State Condition
Description
NAVIGATION_COMPLETE (NavigationCompleteAppState)
  • SUCCESS
  • TARGET_INVALID
  • FAILURE
  • The navigation was successful
  • The navigation target is not valid
  • There was a failure while navigating

Assistant Prompts

Based on the App State and the Condition that was set, the Assistant will speak out an appropriate message to the user. You can examine the default set of prompts configured for the Assistant through the Console and also customize it to your needs. Refer to the Customizing the Assistant section for details.