File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8686 </ div >
8787
8888 < div class = "form-tips" id = "assistantv2-form-tips" >
89- < strong > Note:</ strong > When using multiple sessions, and < code > msg.params.session </ code >
89+ < strong > Note:</ strong > When using multiple sessions, and < code > msg.params.session_id </ code >
9090 is not set then a new session id is generated. < br >
9191 See info box for details.
9292 </ div >
Original file line number Diff line number Diff line change @@ -91,12 +91,45 @@ module.exports = function(RED) {
9191 return Promise . resolve ( ) ;
9292 }
9393
94+ function setSessionID ( msg , config ) {
95+ let session_id = null ;
96+
97+ if ( ! config . multisession ) {
98+ let id = node . context ( ) . flow . get ( 'session_id' ) ;
99+ if ( id ) {
100+ params . session_id = id ;
101+ }
102+ } else if ( msg . params && msg . params . session_id ) {
103+ params . session_id = msg . params . session_id ;
104+ }
105+
106+ return session_id ;
107+ }
108+
109+ function setContext ( msg , config , session_id ) {
110+ let context = null ;
111+ if ( session_id ) {
112+ let c = null
113+ c = node . context ( ) . flow . get ( 'context-' + session_id ) ;
114+ if ( c ) {
115+ context = c ;
116+ }
117+ }
118+ return context ;
119+ }
120+
94121 function buildInputParams ( msg , config ) {
95122 let params = {
96123 'message_type' : 'text' ,
97- 'input' : msg . payload
124+ 'input' : msg . payload ,
125+ 'session_id' : setSessionID ( msg , config )
98126 } ;
99127
128+ let context = setContext ( msg , config , params . session_id ) ;
129+ if ( context ) {
130+ params . context = context ;
131+ // Look for additional context
132+ }
100133
101134 return Promise . resolve ( params ) ;
102135 }
You can’t perform that action at this time.
0 commit comments