我们可以修改现有的库胶囊吗?

Can we modify existing library capsule?

具体来说,我想查看地理图书馆胶囊中的某些城市。我们正在通过让我们的系统调用 API.

来进行基于城市的搜索

我们最后要完成的是确保用户可以在我们有可用房源的城市进行搜索,并防止他们在我们没有覆盖的地方搜索无果。其中很大一部分是限制我们将在其中进行搜索的城市,所以我希望我们可以限制地理图书馆将识别的内容。另一部分是,如果城市名称可能表示多个州,我们希望根据我们支持的城市动态地进行一些消歧状态提示。

所以 TLDR:有什么方法可以自定义内置的库胶囊吗?

您不需要对地理库胶囊进行任何自定义。

您只需让您的 Action 获取用户的位置并添加逻辑以根据您的位置要求检查它,然后再决定是否涵盖与特定用户相关的地点并为用户提供适当的输出。

添加代码解释评论:

行动 1 模型:

action (Action1) {
  description (Checks to see if initial input can be served)
  type (Search)
  collect {
    input (initialInput) {
      type (InitialInput)
      min (Required) max (One)
    }
  }

  output (VerifiedInput)
}

动作 2 模型:

action (Action2) {
  description (Does the search)
  type (Search)
  collect {
    input (verifiedInput) {
      type (VerifiedInput)
      min (Required) max (One)
      default-init {
        intent {
          goal:Action1
        }
      }
    }
    input (searchParameters) {
      type (SearchParameters)
      min (Required) max (Many)
    }
  }

  output (FinalOutput)
}

您将训练话语以达到 Action2 的目标,并且由于其输入之一的 default-init 需要启动 Action1,Bixby 将经过 Action1 先通过 Action2.