Details about the Search user journey

The onSearch callback

Whenever 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:

SearchUserJourney.AppState onSearch(SearchInfo searchInfo, SearchUserJourney userJourney);

When this callback is invoked, the app is expected to:

  1. Consume the details of the search request via the SearchInfo parameter.

  2. Fire the app's search request.

  3. Finally, return the AppState along with Condition 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:

public SearchUserJourney.AppState onSearch(SearchInfo searchInfo, SearchUserJourney searchJourney) {
   String sourceCity = searchInfo.getSrcCity().getName() 
   String destinationCity = searchInfo.getDestCity().getName() 
   Date travelDate = searchInfo.getItem().getDescription();
   // Launch SearchResultsActivity using "searchItem"
   // ...
   return SearchUserJourney.AppState.SEARCH_RESULTS;

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

The SearchInfo parameter contains the breakdown of the original search request. It's structure is as described below:

Class SearchInfo {
    public TravelMode getTravelMode();  //Bus/Train/Flight
    public Station getSource();          //Details of the travel starting point 
    public Station getDestination();     //Details of the travel destination point 
    public Date getOnwardDate();         //Details of the journey date
    public TimeRange getOnwardDepartureTimeRange();
    public TimeRange getOnwardArrivalTimeRange();
    public TripType getTripType();
    public Date getReturnDate();
    public TimeRange getReturnDepartureTimeRange();
    public TimeRange getReturnArrivalTimeRange();
    public List<FilterInfo> getFilters();
    public SortInfo getSortInfo();
    public PriceInfo getPriceInfo();
    public PassengersInfo getPassengersInfo();

Class Station {
    public String getId();        //App provided
    public String getCode();      //Station code if any.
    public String getTerminal();  //Stop name if any.
    public String getCity();      //City name
    public String getProvince();  //State name
    public String getCountry();   //Country name

Enum TravelMode {

Class TimeRange {
    public Date getStartTime();
    public Date getEndTime();

Class PriceInfo {
    public int getMinPrice();
    public int getMaxPrice();
    public Currency getCurrency();

Class FilterInfo {
    public String getFilterValue();
    public String getFilterName();

Class SortInfo {
    public SortType getSortType();
    public SortOrder getSortOrder();

Enum Currency {

Enum SortType {

Enum SortOrder {

Class PassengersInfo {
    public int getCount();
    public PassengerType getPassengerType();

Enum PassengerType {

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 AppStates

The following AppStates 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

The following conditions are supported for each of the AppStates supported by the Assistant

App State




  • 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:

public SearchUserJourney.AppState onSearch(SearchInfo searchInfo, SearchUserJourney searchJourney) {
   String searchItem = searchInfo.getItem().getDescription();
   // Launch SearchResultsActivity using "searchItem"
   // ...
   return SearchUserJourney.AppState.SEARCH_RESULTS;

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