Watson assistant integration [msg.params.session_id]

I'm integrating watson into the telegram. I've done the entire process of flows, functions etc.

However, I have a session problem. in the watson v2 node it shows this parameter of multiple sessions, but I'm not able to store it. Every time I send a message it generates a new session. how could i store it?

[{"id":"a356a8194128f9f2","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"f53ec668a41a80c7","type":"telegram receiver","z":"a356a8194128f9f2","name":"","bot":"1f2b2235e39cce76","saveDataDir":"","filterCommands":false,"x":110,"y":120,"wires":[["84894448938576a3"],[]]},{"id":"5bf0e9e722287738","type":"telegram sender","z":"a356a8194128f9f2","name":"","bot":"1f2b2235e39cce76","haserroroutput":false,"outputs":1,"x":530,"y":540,"wires":[[]]},{"id":"c5e2487228d0016c","type":"watson-assistant-v2","z":"a356a8194128f9f2","name":"Albert","service-endpoint":"https://api.us-south.assistant.watson.cloud.ibm.com/instances/f7d07c5e-8056-456e-99d5-ac64a4c0c2d9","assistant_id":"a28ada9a-8b42-4af5-9f57-73e99b4fb6e3","debug":false,"restart":false,"return_context":false,"alternate_intents":false,"multisession":true,"timeout":"","optout-learning":false,"persist-session-id":false,"credentials":{},"x":530,"y":200,"wires":[["e8f4bd2e0102ddc9"]]},{"id":"84894448938576a3","type":"change","z":"a356a8194128f9f2","name":"","rules":[{"t":"move","p":"payload.type","pt":"msg","to":"context.type","tot":"flow"},{"t":"move","p":"payload.chatId","pt":"msg","to":"context.chatId","tot":"flow"},{"t":"move","p":"payload.content","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":160,"wires":[["810442dc0356190b","c5e2487228d0016c"]]},{"id":"e8f4bd2e0102ddc9","type":"change","z":"a356a8194128f9f2","name":"","rules":[{"t":"move","p":"context.type","pt":"flow","to":"payload.type","tot":"msg"},{"t":"move","p":"context.chatId","pt":"flow","to":"payload.chatId","tot":"msg"},{"t":"move","p":"payload.output.generic","pt":"msg","to":"payload.content","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":340,"wires":[["e0138b00174b58b1"]]},{"id":"ee54b69c28afaec5","type":"function","z":"a356a8194128f9f2","name":"main function","func":"var typemsg = msg.payload.type;\nconst chatId = msg.payload.chatId;\nvar opts = msg.payload.options;\nvar sessionId = msg.payload.session_id;\nvar userId = msg.payload.user_id;\n\n\nvar msgMsg = msg.payload.content;\nvar tamanho = msg.payload.content.length;\nvar newMsg = [];\n\n\nif (msg.payload.content == \"\" && msg.payload.response_type == \"text\"){\n    msg.payload.content = go;\n}\n\n\n\n/*\n\n//mode 1\n\n\nfor (var index = 0; index < tamanho; index++){\n    var resType = msg.payload.content[index].response_type;\n    \n    switch(resType){\n        \n        \n    case \"text\":\n    newMsg.push({\n        payload:\n            {\n            type:typemsg,\n            chatId:chatId,\n            content:msgMsg[index].text,\n            response_type: resType\n            }\n        })\n    break;\n    \n    \n    case \"option\":\n        newMsg.push({\n        payload:\n            {\n            type:typemsg,\n            chatId:chatId,\n            content:msgMsg[index].title,\n            response_type: resType,\n            options: opts\n            }\n        })\n    break;\n    }\n    }\n    \n    context.set(\"inline_keyboard\",true);\n\nreturn [newMsg];\n\n*/\n\n\nfor (var index = 0; index < tamanho; index++){\n    var resType = msg.payload.content[index].response_type;\n    if (resType == \"text\"){\n        newMsg.push({\n        payload:\n            {\n            type:typemsg,\n            chatId:chatId,\n            session_id: sessionId,\n            user_id: userId,\n            content:msgMsg[index].text,\n            response_type: resType\n            \n            }\n            \n        })\n    }    \n    \n    else {\n        newMsg.push({\n        payload:\n            {\n            type:typemsg,\n            chatId:chatId,\n            session_id: sessionId,\n            user_id: userId,\n            content:msgMsg[index].title,\n            response_type: resType,\n            options: opts\n        }\n        })\n    }\n    \n}\n\n\n\nreturn [newMsg];\n\n\n\n\n\n\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":420,"wires":[["7df5b5c78f4960e7"]]},{"id":"f8bbf64fbc962316","type":"inject","z":"a356a8194128f9f2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":1430,"y":1240,"wires":[["3b469bd5ce492aa8"]]},{"id":"3b469bd5ce492aa8","type":"template","z":"a356a8194128f9f2","name":"","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n    \"name\": \"john\",\n    \"birthday\": 2002,\n    \"movies\": [\n        {\n            \"adventure\": \"Avatar\",\n            \"action\": \"Rambo\",\n            \"fiction\": \"interstellar\"\n        },\n        {\n            \"horror\": \"choose one\",\n            \"options\": [\n                {\n                    \"type1\": \"psychological\",\n                    \"type2\": \"visual\"\n                }\n            ]\n        }\n    ]\n}","output":"json","x":1520,"y":1120,"wires":[["e57f387dbe1e8bf1","3f91816b0e7ed1f2"]]},{"id":"e57f387dbe1e8bf1","type":"function","z":"a356a8194128f9f2","name":"payload","func":"/*\nlet list = msg.payload.movies;\nvar msglist = [];\nlet tamanho = msg.payload.movies.length\n\nfor (var indexi = 0; indexi < tamanho; indexi++){\n        msglist.push({payload:list[indexi]});\n    }\n\nreturn [msglist];\n*/\n\nlet msglist = []\n\nmsg.payload.movies.forEach(el => {\n    if(Array.isArray(el.options)){\n        msg.payload.movies[1].options.forEach(es => {\n            msglist.push(es)\n        })\n    }else {\n        msglist.push(el)\n    }\n})\n\nreturn [ msglist ]","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1660,"y":1280,"wires":[["3f91816b0e7ed1f2"]]},{"id":"3f91816b0e7ed1f2","type":"debug","z":"a356a8194128f9f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1730,"y":1120,"wires":[]},{"id":"37160045f2ada83c","type":"template","z":"a356a8194128f9f2","name":"payload.options","field":"payload.options","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n    \"reply_markup\": {\n            \"inline_keyboard\": \n            [\n                [\n                {\n                    \"text\": \"Vídeo de treinamento\",\n                    \"callback_data\": \"Ver vídeo\"\n            \n                }, \n                {\n                    \"text\": \"Corrigir um problema\",\n                    \"callback_data\": \"Corrigir\"            \n                },\n                                {\n                    \"text\": \"Transferir p/ consultor\",\n                    \"callback_data\": \"Transferir\"            \n                }\n                ]\n            ]\n        }\n    }\n    ","output":"json","x":300,"y":420,"wires":[["ee54b69c28afaec5"]]},{"id":"e0138b00174b58b1","type":"function","z":"a356a8194128f9f2","name":"callback_query","func":"if (msg.payload.type == \"callback_query\"){\n    msg.payload.type = \"message\"\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":340,"wires":[["37160045f2ada83c"]]},{"id":"5e06fde3b3df9161","type":"telegram event","z":"a356a8194128f9f2","name":"","bot":"1f2b2235e39cce76","event":"callback_query","autoanswer":false,"x":120,"y":200,"wires":[["84894448938576a3"]]},{"id":"7df5b5c78f4960e7","type":"switch","z":"a356a8194128f9f2","name":"","property":"payload.response_type","propertyType":"msg","rules":[{"t":"eq","v":"text","vt":"str"},{"t":"eq","v":"option","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":270,"y":500,"wires":[["5bf0e9e722287738"],["5317fc7847660b68"]]},{"id":"5317fc7847660b68","type":"delay","z":"a356a8194128f9f2","name":"","pauseType":"delay","timeout":"0.5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":260,"y":580,"wires":[["5bf0e9e722287738"]]},{"id":"810442dc0356190b","type":"function","z":"a356a8194128f9f2","d":true,"name":"","func":"var nmsg= []\n\n\nvar con = msg.payload;\n\nvar session_id = \"session\"\n\nnmsg.push({payload:{\n        content:con,\n        session_id: session_id\n}});\n\n\nreturn nmsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":240,"wires":[["c5e2487228d0016c"]]},{"id":"1f2b2235e39cce76","type":"telegram bot","botname":"albert_radinfo_bot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]

understand how it works. Before the Watson node the msg.params.session_id has to be defined with some identification string. Add a node, for example switch and set this parameter as something unique.