Search
Details about the Search user journey
The onSearch
callback
onSearch
callbackWhenever the Assistant detects that the user is searching for items in the app, it will try to break down the search request into its basic components and invoke the onSearch
callback associated with the search user journey. The callback looks like this:
When this callback is invoked, the app is expected to:
Consume the details of the search request via the
SearchInfo
parameter.Fire the app's search request.
Finally, return the
AppState
along withCondition
corresponding to the state that the app transitioned into.
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:
Sample Utterances that could trigger the search journey
The following are some examples of commands that could trigger this journey
"Bangalore to Chennai"
"Book a ticket to Mumbai"
"Trains from Delhi "
SearchInfo
Parameter
SearchInfo
ParameterThe SearchInfo
parameter contains the breakdown of the original search request. It's structure is as described below:
To illustrate, when the user says "Book a bus from Banglaore to chennai tomorrow ", the following will be set in the SearchInfo
object
getTravelMode() = TravelMode.BUS
getSource().getCity() = "bangalore"
getDestination().getCity() = "chennai"
getOnwardDate() = Date(<next day>)
Supported AppState
s
AppState
sThe following AppState
s are supported:
SEARCH_RESULTS : To be returned when the app performs a search and navigates to the search results screen. To indicate whether the search was successful or not, with a greater level of detail, please use the appropriate conditions.
UNSUPPORTED : To be returned when the app is not ready to handle search yet. The Assistant will let the user know that the search is not yet supported by the app.
The Slang Travel Assistant provides a special AppState
called WAITING
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
Conditions
The following conditions are supported for each of the AppState
s supported by the Assistant
App State
Condition
Description
SEARCH_RESULTS
setSuccess()
setRouteNotFound()
setTicketNotAvailable()
setNeedSource()/ setNeedDestination()
setSourceInvalid()/ setDestinationInvalid()
setSourceAmbiguous()/ setDestinationAmbiguous()
setFailure()
The search was successful
The item being searched could not be found
The item being searched is out of stock
The item that needs to be searched has not been specified.
There was a failure while searching
For example, to indicate to the Assistant that the particular item being searched was not found by the app, the app should do the following:
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