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

前端 未结 3 1157
南笙
南笙 2020-12-04 03:19

I am using this, but this only sets it to empty,

{
  \"context\": {
    \"time\": \"\",
    \"place\": \"\",
    \"things\": \"\",
    \"transport\": \"\"
           


        
相关标签:
3条回答
  • 2020-12-04 03:32

    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
      }
    }
    
    0 讨论(0)
  • 2020-12-04 03:38

    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"
        }
      }
    }
    
    0 讨论(0)
  • 2020-12-04 03:39

    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.

    0 讨论(0)
提交回复
热议问题