3

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

{
  "context": {
    "time": "",
    "place": "",
    "things": "",
    "transport": ""
  },
  "output": {}
}

I also tried "time": "null" and "time": "$time.remove"

data_henrik
  • 16,724
  • 2
  • 28
  • 49
SamuelNLP
  • 4,038
  • 9
  • 59
  • 102

3 Answers3

18

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
  }
}

Setting the variable to null can also be performed in the dialog form when assigning values to variables.

data_henrik
  • 16,724
  • 2
  • 28
  • 49
  • If we add child node and empty the context variable there, it gets removed before the response triggers thus causing the variable to be missed in response. Do you know a solution to this problem? – Anubhav Gupta May 29 '18 at 11:49
  • Could you ask this as new question and add details? – data_henrik May 29 '18 at 12:01
  • @Airtrag I updated my answer to reflect the different API versions. The method has changed with newer API versions. – data_henrik Mar 02 '19 at 08:58
3

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.

Anubhav Gupta
  • 560
  • 6
  • 11
2

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"
    }
  }
}
sdenning
  • 21
  • 1