1

How do I bring the value of an external concept into a result view? What I have is:

 result-view {
 match: AltBrainsData (this) 

      message {
        if (size(this) > 1) {
        template ("Here are some AltBrains I found on search term")
        }
        else-if (size(this) == 0 )
     {template ("I couldn't find any AltBrains matching that search term")}  }

What I want is to say "on search term #{value(searchterm)}" which is an optional parameter in the initial search function. but the result view doesn't seem to know about the concept.

Fred Zimmerman
  • 1,178
  • 3
  • 13
  • 29

2 Answers2

1

Try this

result-view {
 match: AltBrainsData (this)
 from-output: <NameOfAction> (action)

      message {
        if (size(this) > 1) {
        template ("Here are some AltBrains I found on #{value(action.searchTerm)}")
        }
        else-if (size(this) == 0 )
     {template ("I couldn't find any AltBrains matching that #{value(action.searchTerm)}")}  }

Here is another example from the documentationat https://bixbydevelopers.com/dev/docs/dev-guide/developers/customizing-plan.match-patterns

dialog (Result) {
  match: PercentDailyCholesterol (this) {
    min (Required) max (One)
    from-property: NutritionInformation (source)
  }
  template ("One portion of #{value(source.food)} will meet #{percent(this)} of your daily needs for cholesterol.")
}
1

Looking at the code, one additional thought, instead of (size(this) == 0 ) you could also use NoResult e.g.

dialog (NoResult)

There are more complex options available as well. In an action, you can specify what happens if there is empty output e.g.

 output (Result) {
    on-empty {
       . . . [On empty markup]
    }
 }

This allows you to do change the input and re-execute - there are several options see https://bixbydevelopers.com/dev/docs/dev-guide/developers/customizing-plan.effects#handling-empty-output

rogerkibbe
  • 358
  • 2
  • 10