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:

public CheckoutAppState onCheckOut(CheckoutInfo checkoutInfo, CheckoutUserJourney checkoutUserJourney) {
  1. Start the process by navigating to the first page of the checkout journey

  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. 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

public CheckoutAppState onCheckOut(CheckoutInfo checkoutInfo, CheckoutUserJourney checkoutUserJourney) {

   if (checkoutInfo.getCheckoutName() == null) {
     return new CheckoutCompleteAppState(
       CheckoutCompleteAppState.NAME_NOT_SPECIFIED
     );
   } else if (checkoutInfo.getCheckoutPhoneNumber() == null) {
     return new CheckoutCompleteAppState(
       CheckoutCompleteAppState.PHONE_NUMBER_NOT_SPECIFIED
     );
   } else return new CheckoutCompleteAppState(
       CheckoutCompleteAppState.SUCCESS
     );
 }

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:

Class CheckoutInfo {
	String getCheckoutPhoneNumber(); 
	String getCheckoutName(); 
	Date getCheckoutDate();
}

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

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.

Last updated