Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
818 views
in Technique[技术] by (71.8m points)

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

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"

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...