How to remove a context variable in Watson Assistant service on IBM Cloud

﹥>﹥吖頭↗ 提交于 2019-11-28 02:10:35

For those using Watson Assistant on an older API version:

The best is to use context.remove() in the output section. I usually have an extra child node for cleanup.

{
  "output": {
    "text": {},
    "deleted": "<? context.remove('eventName') ?> <? context.remove('queryPredicate') ?>"
  }
}

Because deleted is not part of the context section it won't be carried forward.

For those on recent API versions of Watson Assistant:

Set the variable to null. Here is the doc on "Deleting a context variable".

{
  "context": {
    "myvariable": null
  }
}

You can also add a child node and add jump to the child node after response with the condition set to true and set the context variable to null there.

I believe the following does what you want.

{
  "output": {
    "text": {
      "values": [
        "Ok got it: $Var1, $Var2, $Var3. <? $Var1 = NULL ?> <? $Var2 = NULL ?> <? $Var3 = NULL ?>"
      ],
      "selection_policy": "sequential"
    }
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!