首页 > 解决方案 > 如何为新用户提供不同的结果视图

问题描述

如何为新用户提供不同的结果视图消息或布局?

在这种情况下,我希望视图根据用户是否为新用户而有所不同,如 UserData 概念所示,我在操作 GetAltBrainsData 中计算其值。我已经为 UserData 提供了存储的功能配置文件。

result-view {
  match: AltBrainsData (this) 
  { 
  from-output: GetAltBrainsData (getaltbrainsdata)
  }

  message {

    //here is where i want to check if UserData.newuser = true and vary the answer
  //if (userdata.newuser) {template("hello new user")} else ...


    if (size(this) > 1) {
    template ("I found #{(size(this))} AltBrains")
    }
    else-if (size(this) == 1 ) {
    template ("") {speech ("#{value(this.name)}")}
    }
    else {template ("No AltBrains matched the search.")}
     }

  render {

    // if UserData.newuser = true then welcome layout

但结果视图似乎仍然不知道 UserData。IDE 抱怨它是 userdata.newuser 中的非法表达式

标签: bixby

解决方案


试试if (getaltbrainsdata.userdata.newuser),或者你UserData在你的动作模型中命名的任何东西。

解决此问题的另一种方法是使用匹配模式访问它,例如

result-view {
  match: AltBrainsData (this) 
  { 
  from-output: GetAltBrainsData (getaltbrainsdata) {
      from-input: UserData (userData)
  }
...

推荐阅读