Checkout
Details about the Checkout user journey
The onCheckout
callback
onCheckout
callbackWhen 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) {
Start the process by navigating to the first page of the checkout journey
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
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
CheckoutInfo
ParameterThe parameterCheckoutInfo
contains the breakdown of the original order request. It has the following structure:
Class CheckoutInfo {
String getCheckoutPhoneNumber();
String getCheckoutName();
Date getCheckoutDate();
}
Supported AppState
s
AppState
sThe following AppState
s are supported:
CHECKOUT_COMPLETE (
CheckoutCompleteAppState
): To be returned when the app handles the checkout processUNSUPPORTED (
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.
Supported Condition
s
Condition
sThe following Conditions
are supported for each of the AppState
s 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.
Last updated
Was this helpful?