Search…
Checkout
Details about the Checkout user journey

The onCheckout callback

When the Assistant detects that the user is trying to checkout, it invokes the callback associated with the checkout user journey. The callback looks like this:
Android Native
React Native
Web
1
public CheckoutAppState onCheckOut(CheckoutInfo checkoutInfo, CheckoutUserJourney checkoutUserJourney) {
Copied!
1
TBD
Copied!
1
TBD
Copied!
  1. 1.
    Start the process by navigating to the first page of the checkout journey
  2. 2.
    Now the journey provides ways to collect some relevant inputs from the user if required. The app should return the appropriate app state and condition to indicate which details need to be collected
  3. 3.
    If no data needs to be collected, it can just return SUCCESS condition for the CheckoutComplete AppState
For example, if the app needs to collect the name and then phone number of the user, it can do that as shown below
Android Native
React Native
Web
1
public CheckoutAppState onCheckOut(CheckoutInfo checkoutInfo, CheckoutUserJourney checkoutUserJourney) {
2
3
if (checkoutInfo.getCheckoutName() == null) {
4
return new CheckoutCompleteAppState(
5
CheckoutCompleteAppState.NAME_NOT_SPECIFIED
6
);
7
} else if (checkoutInfo.getCheckoutPhoneNumber() == null) {
8
return new CheckoutCompleteAppState(
9
CheckoutCompleteAppState.PHONE_NUMBER_NOT_SPECIFIED
10
);
11
} else return new CheckoutCompleteAppState(
12
CheckoutCompleteAppState.SUCCESS
13
);
14
}
Copied!
1
TBD
Copied!
1
TBD
Copied!

Sample Utterances that could trigger Checkout

The following are some examples of commands that could trigger this user journey
  • "checkout"
  • "i am done

CheckoutInfo Parameter

The parameterCheckoutInfo contains the breakdown of the original order request. It has the following structure:
Android Native
React Native
Web
1
Class CheckoutInfo {
2
String getCheckoutPhoneNumber();
3
String getCheckoutName();
4
Date getCheckoutDate();
5
}
Copied!
1
TBD
Copied!
1
TBD
Copied!

Supported AppStates

The following AppStates are supported:
  • CHECKOUT_COMPLETE (CheckoutCompleteAppState): To be returned when the app handles the checkout process
  • UNSUPPORTED (UnsupportedAppState): To be returned when the app is not ready to handle checkout via voice yet. The Assistant will speak out an appropriate prompt to the user.
The Slang Retail Assistant provides a special AppState call 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
Condition
CHECKOUT_COMPLETE (CheckoutCompleteAppState)
  • SUCCESS - The order could be shown successfully
  • NAME_NOT_SPECIFIED - The app wants to collect the user's name associated with the order
  • PHONE_NUMBER_NOT_SPECIFIED - The app wants to collect the phone number to be used for the order
  • DATE_NOT_SPECIFIED - The app wants to collect the delivery date for the order
  • FAILURE - There was a failure during the checkout process

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.