Uh oh! We couldn’t find any match.

Please try other search keywords.

Bixby Developer Center

Guides

Default Values

Bixby provides ways to provide default values to the user.

Let's say you are building a tip calculator and one of the required inputs to calculating a tip on a bill is the tip percentage. If a user asks, "What's a good tip on a $100 bill," they haven't specified a tip percentage. Without any additional developer contributions, the user would be told Bixby can't calculate that without a percentage to tip. As the developer, you have a few different ways to think about the experience to get that required value:

  • Does the user need to learn to include tip percentage in their request?
  • Should the user be prompted with a form to enter a percentage every time?
  • Should Bixby consider some default percentages and then use Selection Learning to automatically use one of those values in future requests?

Instead of always asking the user for a tip percentage, you can provide an instantiation strategy that suggests a number of suggested value when the user hasn't specified one. More than one instantiation strategy can apply to a given situation if there is a match pattern that applies. Bixby combines all the results that they generate. In the examples that follow, you'll see that you can specify a fixed number of predefined results, or even specify the way Bixby should find the needed values through an intent.

Another way you can directly specify possible values for required inputs is through default-init annotations for a given action input. For example, the receipt for an event may be required and the developer can specify an intent for how to create it for the user.

input (receipt) {
type (Receipt)
min (Required)
hidden
plan-behavior (Never)
default-init {
intent {
goal: FinalizeTransaction
value: $expr(tempCart)
}
}
}

Bixby will first consider any developer-specified default-init values when looking for required missing values. If none are present nor apply to the current request Bixby will only then consider instantiation strategies. Note that default values can be functionally equivalent to a corresponding instantiation strategy. Besides being co-located with the action that may use the value(s), they can also specify more complicated conditional checks and be tied to other constructs, e.g. variables.

In the example below, the capsule looks for the most appropriate user profile address to use as a default delivery address when creating a restaurant order when home and work addresses are nearby. Note that instantiation-behavior (ShowDefaultValueDecision) is specified to explicitly show that choice was made to the user, like a selection prompt.

Note

Keep in mind that there is no validation when you use instantiation-behavior (ShowDefaultValueDecision). To learn more, read about instantiation-behavior in the reference guide.

variable (deliveryAddress) {
type (viv.restaurant.DeliveryAddress)
min (Required) max (One)
instantiation-behavior (ShowDefaultValueDecision)
default-init {
if (exists(homeDistance) && homeDistance.magnitude < 1 && exists(workDistance) && workDistance.magnitude < 1) {
if (homeDistance.magnitude <= workDistance.magnitude) {
intent{
goal: viv.restaurant.DeliveryAddress
value: viv.restaurant.DeliveryAddress {
name: viv.geo.PlaceName(home)
address: $expr(home)
point: $expr(home.centroid)
}
}
} else {
intent {
goal: viv.restaurant.DeliveryAddress
value: viv.restaurant.DeliveryAddress {
name: viv.geo.PlaceName(work)
address: $expr(work)
point: $expr(work.centroid)
}
}
}
}
if (exists(homeDistance) && homeDistance.magnitude < 1) {
value: viv.restaurant.DeliveryAddress {
name: viv.geo.PlaceName(home)
address: $expr(home)
point: $expr(home.centroid)
}
}
if (exists(workDistance) && workDistance.magnitude < 1) {
value: viv.restaurant.DeliveryAddress {
name: viv.geo.PlaceName(work)
address: $expr(work)
point: $expr(work.centroid)
}
}
}
}

Instantiation strategies have all the common components of a strategy in Bixby. The main differentiator is the strategy block. It determines either the values to use, or where to get those value(s) in intent form. See Instantiation Strategies for more details.

Instantiation Strategy Example - Weather

Consider the case when the user makes a query such as: "How is the weather?"

In this case, the weather capsule requires a location. An instantiation strategy provides a way to supply that value to Bixby. This example below specifies and instantiation strategy as an intent. Bixby executes this intent in order to get a potential location. In this strategy, it supplies the user's current location.

instantiation-strategy {
id (current-location-value)
match {
viv.geo.CurrentLocation
}

strategy {
intent {
goal-set: viv.geo.CurrentLocation { $expr ($user.currentLocation) }
}
}
}

Multiple instantiation strategies can be defined and matched for a given execution. In that case, Bixby will merge all values that are returned and use them as part of its execution.

Note

If more options are returned than are needed Selection Learning will be called to help choose the best options for the user.

Instantiation Strategy Example - Sending Money

This next example shows how Bixby can use instantiation strategies to demonstrate some location-dependent intelligence. During a transaction involving currency, it can be awkward to require the currency type in every request. With the instantiation strategy below, Bixby can use a user's country locale and have Bixby automatically display some level of intelligence about the user's context.

instantiation-strategy {
id (money.Currency_Instantiation)
match {
viv.money.Currency
}
strategy {
intent {
subplan {
value-set {
geo.ISOCountryCode2 {
$expr($user.locale.country)
}
}
goal { viv.money.CurrencyType }
}
goal { viv.money.Currency }
}
}
}

Instantiation Strategy Example - Tip Calculator

The instantiation strategy below gives Bixby some typical tip percentages to consider when a user fails to specify a tip percentage. This example includes explicit values as explicit values, which makes them always available. Note that the order of these defined values also has a role in Selection Learning as a default value.

instantiation-strategy {
id (init-tip-percent-from-dflt-enum)
match {
viv.gratuity.TipPercent (this)
}
strategy {
intent {
value: viv.gratuity.TipPercent (10)
value: viv.gratuity.TipPercent (15)
value: viv.gratuity.TipPercent (18)
value: viv.gratuity.TipPercent (20)
value: viv.gratuity.TipPercent (25)
goal: viv.gratuity.TipPercent
}
}
}