Search code examples
bixby

Dialog for SpaceResorts after selecting a resort


I would like to have Bixby read out the description after selecting a resort. Since the description is not shown when all resorts are being displayed, it'd be nice to have the description dialog after selecting a resort.

I am trying to get the dialog for when result == 1. I have tried to create a dialog to match ViewAll from-property SpaceResort, but still have not been able to get any custom dialog.

result-view {
  match {
    ViewAll(all) {
      from-property {
        SpaceResort (result)
      }
    }
  }

  message {
    template-macro (SPACE_RESORT_RESULT) {
      param (result) {expression (result)}
    }
  }

  render {
    if (size(result) > 1) {
      list-of (result) {
        where-each (item) {
          layout-macro (space-resort-summary) {
            param (spaceResort) {
              expression(item)
            }
          }
        }
 layout
        highlights {
          select(pick) {
            label {
              template-macro (HIGHLIGHT_LABEL_BY_PREFERENCES)
            }
            layout-macro (space-resort-highlight) {
              param (spaceResort) {
                expression(pick)
              }
            }
            order-by {
              sorting (pick) {
                by-preferences
              }
            }
          }
          select(pick) {
            label("#{raw(pick.highlight)}")
            layout-macro (space-resort-highlight) {
              param (spaceResort) {
                expression(pick)
              }
            }
            filter-by (exists(pick.highlight))
          }
          select(pick) {
            label("#{raw(pick.highlight)}")
            layout-macro (space-resort-highlight) {
              param (spaceResort) {
                expression(pick)
              }
            }
            filter-by (exists(pick.highlight))
          }
          select(pick) {
            label("#{raw(pick.highlight)}")
            layout-macro (space-resort-highlight) {
              param (spaceResort) {
                expression(pick)
              }
            }
            filter-by (exists(pick.highlight))
          }
        }
      }
    } else-if (size(result) == 1) {
      layout-macro (space-resort-details) {
        param (spaceResort) {
          expression (result)
        }
      }
    }
  }

  conversation-drivers {
    if ("size(result) == 1") {
      conversation-driver {
        template-macro (MakeReservation)
      }
    }
  }
}

Solution

  • Go to resources/en/dialogs/ and created a dialog called selected_planet.dialog.bxb.

    Create a dialog with this code:

    dialog (Result) {
      match: SpaceResort (this)
    
      template("You selected this planet!.") {
        speech ("#{value(this.description)}")
      }
    }
    

    The description will now be read out loud by Bixby.

    To test this: Say "Give me a space resort near mars" and select one of the options that appear.