我定义了一个对话对话框,在其中我在一个节点中设置了变量重复:
{
"output": {
"text": "You said: <?input_text?>. Let's fix the @product. "
},
"context": {
"repeat": "<?input.text?>"
}
}
并在后续节点中显示了变量 $repeat:
{
"output": {
"text": "repeat: $repeat"
}
}
如何在 Swift 中访问此变量 $repeat?我可以访问包含相同文本的 response.input.text,但我想访问 $repeat,以便更加灵活。
输入:
radio broken
输出:
You said: radio broken. Let's fix the radio.
repeat: radio broken
SWIFT代码:
var context: Context? // initial definition
...
func next_dialog(input_text: String) {
conversation = Conversation(username: username, password: password, version: version)
let failure = { (error: NSError) in print(error) }
conversation.message(workspaceID, text: input_text, context: self.context, failure: failure) { response in
self.context = response.context // update with response.context
...
语境: