Drive the user with Smart Suggestions
  • Updated on 08 Sep 2019
  • 2 minutes to read
  • Contributors
  • Print
  • Share
  • Dark
    Light

Drive the user with Smart Suggestions

  • Print
  • Share
  • Dark
    Light

In order to drive an App conversation in a purposeful direction, the user can be prompted to select from a number of Smart Suggestions.

Smart Suggestions have multiple purposes:

  1. To help users make common questions and requests;
  2. To guide users through a workflow;
  3. To give the user ideas for potentially useful questions and requests;
  4. To help new users use the system;
  5. To prepare the App for potential future next steps in a workflow.

Smart Suggestions appear graphically at the bottom of the conversation as UI elements called ‘Chips’. When the user touches a Chip, the App will type the message as if the user had typed it themselves.

How to create Smart Suggestions

Smart Suggestions are directly linked with Intents. It’s perhaps helpful to imagine an Intent as a container that holds multiple Smart Suggestions.

The code block below shows how to add Smart Suggestions to an Intent:

let q1 = new Intent(Q1);
q1.setEnglishSmartSuggestions(['Hello', 'Hi']);

Once an Intent is added to an App and used, the system will start learning and the Smart Suggestions will start appearing.

Conditional Text

The text of a Smart Suggestion can vary depending on the conditions in the state object. For example, a Smart Suggestion could address a user by their name if they have previously entered it – so instead of just saying "Hello", the suggestion could be "Hello 'person'":

let personCondition = () => {
  let person = state.getField('selectedPerson');
  return !!person;
};
let q2 = new Intent(Q2);
q2.setEnglishSmartSuggestionsWithCondition(
  ['Hello'],
  [`Hello ${state.getField('selectedPerson')}`],
  personCondition
);

The closure personCondition returns ‘true’ or ‘false’ depending on whether a selected person is stored within the state object. If there is one, the suggestion will be "Hello 'person'"; if not, it will display the default "Hello".

Suggestion matching

To match the Smart Suggestion, there is a method within the Intent class called matchSuggestions:

q2.onMatching = () => {
  return q2.matchSuggestions(state.messageFromUser);
};

This method will evaluate if the message sent by the user matches any of the Smart Suggestions within the Intent. It returns ‘true’ if it matches and ‘false’ if it doesn't.

Overriding the Prediction

The developers can override the Machine Learning logic the App uses to predict the next intent if they want to control exactly which Smart Suggestions will be shown to the user. This is done by implementing the closure onPrediction for a given intent:

q2.onPrediction = () => {
  if ([q1.intentId, q3.intentId].indexOf(state.activeIntent) > -1) {
    return 1
  } else if ([q4.intentId, q5.intentId].indexOf(state.activeIntent) > -1) {
    return 0.8
  }
  return 0;
};

Following the Intent Prediction Process, the system at the end of the Intent Execution Hierarchy processes all the available onPrediction closures.

The Machine Learning determines the probability of each intent happening next. If there is an onPrediction closure for a given intent, the ML ignores its own calculations and replaces that probability with the one calculated by the closure.

In the example above, the developer is specifying that if the current intent finalising the process is either q1 or q3, the probability of q2 happening next is 100%. If the current intent is q4 or q5, then the probability is 80%. The probability of q2 happening next is 0% for any other intents.

Was this article helpful?