如何从一组固定值中进行选择?

时间:2019-02-26 19:28:48

标签: bixby bixbystudio

如果我的胶囊需要允许用户从enum表示的一组固定值中进行选择,我该如何在Bixby中做到这一点?

1 个答案:

答案 0 :(得分:1)

我们将固定值表示为枚举

enum (FixedValue) {
  symbol (ONE)
  symbol (TWO)
  symbol (THREE)
  symbol (FOUR)
}

动作文件如下所示

action (GetFixedValue) {
 type(Search)
 description (Allow user to choose a value from the set of fixed values)

 collect{
   input (fixedValue) {
     type (FixedValue)
     min (Required) max (One)
     prompt-behavior (AlwaysElicitation)
     default-init {
       intent {
       goal: FixedValue
       value-set {FixedValue {FixedValue(ONE) FixedValue(TWO) FixedValue(THREE) FixedValue(FOUR) }}
     }
    }
   }
  } output (FixedValue)
}

此操作的Javascript文件如下:

module.exports.function = function GetFixedValue (fixedValue) {
 return JSON.stringify(fixedValue)
}