watson-developer-cloud / node-red-node-watson

A collection of nodes for the IBM Watson services
Apache License 2.0
82 stars 86 forks source link

Problem with watson assistant v2 - new session fix #475

Closed tomkos closed 3 years ago

tomkos commented 4 years ago

Hi, after I've updated my app to the v0.9.2 version, I've notice that invalid sessions error are handled automatically, which is good. But there is another issue, after first reset of session. The session is being restarted every time new request is coming. Behavior:

Anyone had similar behavior?

chughts commented 4 years ago

Two of the changes made in 0.9.1 relate to this issue.

The changes relate to two requirements:

  1. For the node to manage renewal of expired sessions.
  2. For the node to allow the use of identifiers for the session. This was due to flows integrating with nodes like twillio where the session id could not be remembered, but other ids like a telephone number could.

So as of 0.9.1 if you send in a session id, it is used as an identifier. The node maps that to the real session id, which when it expires replaces it.

When you provide a session id, and no mapped session exists for it, then a new 'real' session id is created. When a mapped session exits it is used. When you don't provide a session id, a new mapped session id is created. The naming is off, but pre 0.9.1 that is what was being input.

So for your case, simply carry on providing S1, even when the node starts to emit S2.

I am keeping this issue open as:

  1. The info panel needs to be more explicit on this usage
  2. The node, could be amended to output the input session id. ie. always output S1, even when S1 is expired and all S1 is being used is as a look up for the live session id.
tomkos commented 4 years ago

I need to test it, as this is not that clear to me :D Basically this is very good, that node manage the session, so I will give it a try.

tomkos commented 3 years ago

We are strugglling a bit with this feature, as this is not backward compatible.... and now if we would like to upgrade to latest version, we would need to rework many integration points, is it possible to have some config property to turn it on or off? Or node should return S1, even if some real session S2 was created...

chughts commented 3 years ago

I am happy to accept a pull request with this feature.

tomkos commented 3 years ago

Sure, pull request waiting for review and comments