@@ -21,13 +21,18 @@ require('./config/express')(app);
2121const AssistantV2 = require ( 'ibm-watson/assistant/v2' ) ;
2222const uuidV1 = require ( 'uuid/v1' ) ;
2323const NodeCache = require ( 'node-cache' ) ;
24+ const { IamAuthenticator } = require ( 'ibm-watson/auth' ) ;
2425const bank = require ( './lib/bankFunctions' ) ;
2526// stdTTL time in seconds (15 mins)
2627const searchCache = new NodeCache ( { stdTTL : 900 } ) ;
2728
2829// declare Watson Assistant service
2930const assistant = new AssistantV2 ( {
3031 version : '2019-02-28' ,
32+ authenticator : new IamAuthenticator ( {
33+ apikey : process . env . ASSISTANT_IAM_APIKEY ,
34+ } ) ,
35+ url : process . env . ASSISTANT_IAM_URL ,
3136} ) ;
3237
3338const date = new Date ( ) ;
@@ -100,8 +105,8 @@ app.post('/api/message', (req, res) => {
100105
101106 // assemble assistant payload
102107 const payload = {
103- assistant_id : assistantId ,
104- session_id : req . body . session_id ,
108+ assistantId,
109+ sessionId : req . body . session_id ,
105110 input : {
106111 message_type : 'text' ,
107112 text : textIn ,
@@ -151,7 +156,7 @@ app.get('/bank/statement', (req, res) => {
151156
152157app . get ( '/api/session' , ( req , res ) => {
153158 assistant . createSession ( {
154- assistant_id : process . env . ASSISTANT_ID || '{assistant_id}' ,
159+ assistantId : process . env . ASSISTANT_ID || '{assistant_id}' ,
155160 } , ( error , response ) => {
156161 if ( error ) {
157162 console . log ( error ) ;
0 commit comments