Bixby Developer Center

Guides
References

replace

optionalvalue required

Effect that replaces an existing input value with a new one. The new value should be a weaker search constraint than the original value.

Examples

Example 1

Let's take the FindBusiness action as an example.

When searching for a local business, the user might not explicitly search for a "Restaurant". However, they might mention other food-related inputs, like "course" or "cuisine". With these inputs, you can modify the search to explicitly look for "Restaurant". This is what the first block of this relaxation strategy shows.

The second block of this relaxation strategy shows how to increase the distance radius for the search if no results were found in the vicinity. Essentially if no results were found within, say 5 miles, then look within 20 miles.

output (Business) {
on-empty {
if ("!relaxed(restaurantStyle) && ((exists(restaurantStyle) && (!contains(restaurantStyle, 'Restaurant') || size(restaurantStyle) > 1)) || exists(allergy) || exists(course) || exists(cuisineAttribute) || exists(cuisineStyle) || exists(diet) || exists(meal) || exists(menuItem) || exists(restaurantAmenities) || exists(restaurantQualities))") {
// If we have reason to believe this is a restaurant query, make that explicit and simple
replace (restaurantStyle) {
intent{
goal { Restaurant }
value { restaurant.RestaurantStyle(Restaurant) }
}
}
} else-if (!relaxed(searchRegion) && searchRegion.searchType == 'PointRadius' && searchRegion.pointRadius.radius.magnitude < 20) {
// Increase search radius
replace (searchRegion) {
intent {
goal { geo.SearchRegion }
value { $expr (searchRegion.pointRadius.centroid) }
value {
geo.SearchRadius {
unit: $expr (searchRegion.pointRadius.radius.unit)
magnitude { geo.DistanceMagnitude(20.0) }
}
}
}
}
}
}
}

Example 2

Instead of dropping an input that has cardinality Many, you might want to reduce it to size 1. For example, if Bixby is struggling to find events that overlap many topics, it might be reasonable to focus on just one topic:

output (event.Event) {
on-empty {
if (exists(topic) && size(topic).length > 1) {
replace(topic) {
intent {
goal : Event
value : $expr(topic[0])
}
}
}
}
}

Example 3

This defaults the time frame to look for an earthquake to 1 year when no results were found.

output (earthquake.Earthquake) {
on-empty {
if (!relaxed(dateInterval)) {
replace (dateInterval) {
intent {
goal { viv.time.DateInterval }
value { viv.time.ExplicitOffsetFromNow(Last) }
value { viv.time.Tense(Past) }
value { viv.time.PeriodYears (1) }
}
}
}
}
}

Child Keys

intent
optional
A set of signals that the Bixby planner interprets to create a plan