代码之家  ›  专栏  ›  技术社区  ›  Ahmed Salah

如何在Watson助手的整个倍增回复节点中创建上下文变量?

  •  0
  • Ahmed Salah  · 技术社区  · 6 年前

    要在只有一个回复的节点中添加一个上下文变量,我只需在该回复中添加一次var,这就足够了。

    但在多个应答节点中,我必须配置每个应答,并使用context或JSON编辑器在每个应答中添加上下文变量。

    我只能加一次吗?

    如果不是的话,背后的想法是什么?

    除了回答特定的变量之外,为什么不存在节点通用变量选项呢?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Simon O'Doherty    6 年前

    多响应节点是一种很容易将不同响应嵌套在一起的方法。在此功能之前,您必须为每个想要执行的响应创建一个节点。

    这似乎是一个副作用,但很容易解决。

    创建主节点并设置上下文变量。然后创建一个子节点并让父节点“跳过用户输入”。子节点应该有多个响应。

    示例工作区:

    {
      "name": "Example single context for multiresponse node",
      "intents": [],
      "entities": [],
      "language": "en",
      "metadata": {
        "api_version": {
          "major_version": "v1",
          "minor_version": "2017-05-26"
        }
      },
      "description": "",
      "dialog_nodes": [
        {
          "type": "response_condition",
          "title": null,
          "output": {
            "generic": [
              {
                "values": [
                  {
                    "text": "two $example"
                  }
                ],
                "response_type": "text"
              }
            ]
          },
          "parent": "node_1_1532968597524",
          "context": null,
          "metadata": {},
          "next_step": null,
          "conditions": "input.text == \"2\"",
          "description": null,
          "dialog_node": "node_3_1532968635994",
          "previous_sibling": "node_2_1532968631610"
        },
        {
          "type": "response_condition",
          "title": null,
          "output": {
            "generic": [
              {
                "values": [
                  {
                    "text": "one $example"
                  }
                ],
                "response_type": "text",
                "selection_policy": "sequential"
              }
            ]
          },
          "parent": "node_1_1532968597524",
          "context": null,
          "metadata": {},
          "next_step": null,
          "conditions": "input.text == \"1\"",
          "description": null,
          "dialog_node": "node_2_1532968631610",
          "previous_sibling": null
        },
        {
          "type": "standard",
          "title": "Enter 1 or 2 to trigger.",
          "output": {},
          "parent": "node_4_1532968810899",
          "context": null,
          "metadata": {
            "_customization": {
              "mcr": true
            }
          },
          "next_step": null,
          "conditions": "anything_else",
          "description": null,
          "dialog_node": "node_1_1532968597524",
          "digress_out": "allow_all",
          "previous_sibling": null
        },
        {
          "type": "standard",
          "title": "$example set to value of \"example\"",
          "output": {
            "generic": [
              {
                "values": [],
                "response_type": "text",
                "selection_policy": "sequential"
              }
            ]
          },
          "parent": null,
          "context": {
            "example": "example"
          },
          "metadata": {},
          "next_step": {
            "behavior": "skip_user_input"
          },
          "conditions": "anything_else",
          "description": null,
          "dialog_node": "node_4_1532968810899",
          "previous_sibling": "Welcome"
        },
        {
          "type": "standard",
          "title": "Anything else",
          "output": {
            "generic": [
              {
                "values": [
                  {
                    "text": "I didn't understand. You can try rephrasing."
                  },
                  {
                    "text": "Can you reword your statement? I'm not understanding."
                  },
                  {
                    "text": "I didn't get your meaning."
                  }
                ],
                "response_type": "text",
                "selection_policy": "sequential"
              }
            ]
          },
          "parent": null,
          "context": null,
          "metadata": {},
          "next_step": null,
          "conditions": "anything_else",
          "description": null,
          "dialog_node": "Anything else",
          "previous_sibling": "node_4_1532968810899"
        },
        {
          "type": "standard",
          "title": "Welcome",
          "output": {
            "generic": [
              {
                "values": [
                  {
                    "text": "Hello. How can I help you?"
                  }
                ],
                "response_type": "text",
                "selection_policy": "sequential"
              }
            ]
          },
          "parent": null,
          "context": null,
          "metadata": {},
          "next_step": null,
          "conditions": "welcome",
          "description": null,
          "dialog_node": "Welcome",
          "previous_sibling": null
        }
      ],
      "workspace_id": "9e5b9851-5f0e-4e5f-9523-d2ac7045bf1d",
      "counterexamples": [],
      "system_settings": {
        "tooling": {
          "store_generic_responses": true
        },
        "disambiguation": {
          "prompt": "Did you mean:",
          "none_of_the_above_prompt": "None of the above"
        },
        "human_agent_assist": {
          "prompt": "Did you mean:"
        }
      },
      "learning_opt_out": false
    }