在向用户显示输入视图时,如何让用户输入 NL?

How can I let the user give NL input when showing them an input-view?

我有一个 capsule 可以根据用户输入计算一些东西。用户需要告诉我的胶囊一个始发国(FromCountryConcept)、目的地国家(ToCountryConcept)和一个文本(LetterContentConcept)。由于国家/地区概念是 enum,因此这些国家/地区的 input-view 很简单 selection-of。对于文本的 input-view,我使用 textarea。所有代码都在下面,并且可以在这个存储库的 github 上找到:SendLetter-Bixby

当用户使用 Bixby 视图向 Bixby 提供所需的输入时,一切都按预期进行。

如何让用户使用(口头或打字)NL 输入向显示的 input-view 提供输入?

我的操作 SendLetter.model.bxb 看起来像这样:

action (SendLetter) {
  description (Sends a Letter from one country to another and calculates the cost based on the letter content length.)
  type (Calculation)
  collect {
    input (fromCountry) {
      type (FromCountryConcept)
      min (Required)
      max (One)
      default-init {
        intent {
          goal: FromCountryConcept
          value-set: FromCountryConcept {
            FromCountryConcept(Germany)
            FromCountryConcept(South Korea)
            FromCountryConcept(USA)
            FromCountryConcept(Spain)
            FromCountryConcept(Austria)
            FromCountryConcept(France)
          }
        }
      }
    }
    input (toCountry) {
      type (ToCountryConcept)
      min (Required)
      max (One)
      default-init {
        intent {
          goal: ToCountryConcept
          value-set: ToCountryConcept {
            ToCountryConcept(Austria)
            ToCountryConcept(South Korea)
            ToCountryConcept(USA)
            ToCountryConcept(Spain)
            ToCountryConcept(Germany)
            ToCountryConcept(France)
          }
        }
      }
    }
    input (letterContent) {
      type (LetterContentConcept)
      min (Required)
      max (One)
    }
  }
  output (SendLetterResponseConcept)
}

国家/地区概念 FromCountry_Input.view.bxbinput-view 如下所示(ToCountry_Input.view.bxb 等效):

input-view {
  match: FromCountryConcept(this)
  message {
    template ("Select the country this letter will be sent from")
  }
  render {
    selection-of (this) {
      where-each (fromCountry) {
        // default-layout used
      }
    }
  }
}

我希望用户能够输入的文本 input-viewLetterContent_Input.view.bxb:

input-view {
  match: LetterContentConcept(this)
  message {
    template ("Write the content of the letter.")
  }
  render {
    form {
      on-submit {
        goal: LetterContentConcept
        value {
          viv.core.FormElement(letterContent)
        }
      }
      elements {
        textarea {
          id (letterContent)
          label ("Letter Content")
          type (LetterContentConcept)
          value ("#{value(this)}")
        }
      }
    }
  }
}

你正处于提示时刻,所以你需要添加提示培训。

这将允许用户使用 NL 来响应您的提示。

在训练选项卡中,它看起来像这样:

https://bixbydevelopers.com/dev/docs/dev-guide/developers/training.intro-training#add-training-examples-for-prompts