ibm-watsonwatson-conversation

Watson Assistant V2 API: change session timeout


Using the Watson Assistant V2 API it is necessary to create a session handle first (create_session(assistantid)) which returns the session ID to use in the individual call to message(assistantid,sessionid,request). The session maintains the conversation state and therefore is the equivalent to the context id parameter of the V1 API.

Unfortunately it seems that there's a 5 minute session timeout by default. The response includes the following header attribute:

{...,"x-watson-session-timeout": [
"x-watson-session-timeout",
                "session_timeout=300"
            ],...}

Any attempt to change this parameter by using the set_default_headers() method of the assistant object or by adding the optional header parameter to the create_session() call seems to have no effect. As I have not found any documentation of how to update this parameter correctly I just tried several alternatives:

1) self.assistant.set_default_headers({'x-watson-session-timeout':"['x-watson-session-timeout','session_timeout=3600']"})

2) self.assistant.set_default_headers({'x-watson-session-timeout':"'x-watson-session-timeout','session_timeout=3600'"})

3)self.assistant.set_default_headers({'x-watson-session-timeout':"session_timeout=3600"})

4)self.assistant.set_default_headers({'x-watson-session-timeout':"3600"})

5)self.assistant.set_default_headers({'session_timeout':"3600"})

Nothing is effective. The value of the parameter in the header of the response is still 300.

Do I use incorrect dict pairs to update the parameter? Is there another way to maintain the conversation state longer than 5 minutes using the V2 API? Is it not possible to change it at all?


Solution

  • The value of the session timeout is not under the control of the caller, and is in fact related to the Assistant plan you are using. For the free and standard the timeout is indeed 5 minutes. For the other plans the timeout is larger.

    See Retaining information across dialog turns

    The current session lasts for as long a user interacts with the assistant, and then up to 60 minutes of inactivity for Plus or Premium plans (5 minutes for Lite or Standard plans).