File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed
Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ module.exports = function(RED) {
128128 function setAlternativeIntentsParams ( node , msg , config , params ) {
129129 // optional alternate_intents : boolean
130130 if ( msg . params && msg . params . alternate_intents ) {
131- params . alternate_intents = msg . params . alternate_intents ;
131+ params . alternateIntents = msg . params . alternate_intents ;
132132 }
133133 }
134134
Original file line number Diff line number Diff line change 9191 < label for = "node-input-optout-learning" style = "width: 70%;" > Opt Out Request Logging</ label >
9292 </ div >
9393
94+ < div class = "form-row" >
95+ < label > </ label >
96+ < input type = "checkbox" id = "node-input-persist-session-id" style = "display: inline-block; width: auto; vertical-align: top;" >
97+ < label for = "node-input-persist-session-id" style = "width: 70%;" > Set to true to return session_id that was provided with request.</ label >
98+ </ div >
99+
94100 < div class = "form-tips" id = "assistantv2-form-tips" >
95101 < strong > Note:</ strong > When using multiple sessions, and < code > msg.params.session_id</ code >
96102 is not set then a new session id is generated. < br >
132138 < li > < code > msg.params.endpoint</ code > : If provided will be used as the url for the Assistant service.</ li >
133139 < li > < code > msg.params.version</ code > : If provided will be used as the API version date for the Assistant service . < / l i >
134140 < li > < code > msg.params.optout_learning</ code > : Set to true to opt out of request logging. Check the < a href = "https://console.bluemix.net/docs/services/watson/getting-started-logging.html#controlling-request-logging-for-watson-services" target = "_blank" > documentation</ a > for details.</ li >
141+ < li > < code > msg.params.persist_session_id</ code > ( optional ) : Set to true to return session_id that was provided with request . < / l i >
135142 < li > < code > msg.params.disable_ssl_verification</ code > : Set to true to disable SSL verification. < b > Note that this has serious security implications - only do this if you really mean to!</ b > </ li >
136143 < / u l >
137144 < p > See < a href = "https://cloud.ibm.com/apidocs/assistant-v2" target = "_blank" > Assistant V2 API documentation</ a > for details.</ p >
202209 alternate_intents : { value : false } ,
203210 multisession : { value : true } ,
204211 timeout : { value : '' , validate : RED . validators . number ( true ) } ,
205- 'optout-learning' : { value : false }
212+ 'optout-learning' : { value : false } ,
213+ 'persist-session-id' : { value : false }
206214 } ,
207215 credentials : {
208216 username : { type :'text' } ,
Original file line number Diff line number Diff line change @@ -368,6 +368,29 @@ module.exports = function(RED) {
368368 } ) ;
369369 }
370370
371+ function setInitialSessionId ( msg ) {
372+ let persistSessionId = false ;
373+ if ( config [ 'persist-session-id' ] ) {
374+ persistSessionId = true ;
375+ }
376+ if ( ( msg . params [ 'persist_session_id' ] ) ) {
377+ persistSessionId = true ;
378+ }
379+ return new Promise ( function resolver ( resolve ) {
380+ if ( persistSessionId ) {
381+ if ( msg . params && msg . params . session_id ) {
382+ if ( msg . payload ) {
383+ msg . payload . session_id = msg . params . session_id ;
384+ if ( msg . payload . context && msg . payload . context . global ) {
385+ msg . payload . context . global . session_id = msg . params . session_id ;
386+ }
387+ }
388+ }
389+ }
390+ resolve ( msg ) ;
391+ } ) ;
392+ }
393+
371394 this . on ( 'input' , function ( msg , send , done ) {
372395 var creds = setCredentials ( msg ) ,
373396 params = { } ;
@@ -406,6 +429,9 @@ module.exports = function(RED) {
406429 msg . payload = body ;
407430 return Promise . resolve ( ) ;
408431 } )
432+ . then ( function ( ) {
433+ return setInitialSessionId ( msg )
434+ } )
409435 . then ( function ( ) {
410436 node . status ( { } ) ;
411437 send ( msg ) ;
You can’t perform that action at this time.
0 commit comments