aws / aws-sdk-js

AWS SDK for JavaScript in the browser and Node.js
https://aws.amazon.com/developer/language/javascript/
Apache License 2.0
7.59k stars 1.55k forks source link

postText doesn't return sessionAttributes for dialogAction type 'Delegate' #3243

Closed plotic closed 4 years ago

plotic commented 4 years ago

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug I'm trying to build a chatbot infrastructure by using AWS API Gateway and AWS Lex. I have attached for API and Lex bot a separate lambda function. When invoking the Lex with lexruntime.postText i trigger the Lex lambda function. In this lambda function i want to set some sessionAttributes and return the response with DialogAction's type "Delegate". The bug is that sessionAttributes are not being returned. But if DialogAction's type is "Close" the sessionAttributes is getting returned.

Is the issue in the browser/Node.js? Node.js

If on Node.js, are you running this on AWS Lambda? YES, AWS almbda

Details of the browser/Node.js version v12.12.0

SDK version number 2.631.0

To Reproduce (observed behavior) Lambda 1 (AWS API Gateway)

  var params = {
        botAlias: '$LATEST',
        botName: 'SampleBot',
        inputText: "hey", 
        sessionAttributes: {},
        userId: "userId"
    };

    return await lexruntime.postText(params, function(err, data) {
        if (err) { 
            console.log(err.errorMessage)
        }
        else {     
            console.log('Lambda invoked')
        }
    }).promise();

Lambda 2


  const welcomeIntent = (intentRequest, callback) => {
    const sessionAttributes = intentRequest.sessionAttributes;        
    if (intentRequest.invocationSource === 'DialogCodeHook') {
        sessionAttributes.someAttribute = "someValue"  
         callback(delegate(sessionAttributes, intentRequest.currentIntent.slots));    
        return
    }
    callback(close(sessionAttributes, 'Fulfilled', { contentType: 'PlainText', content: 'Thanks' }));
  };

  const delegate = (sessionAttributes, slots) => ({
    sessionAttributes,
    dialogAction: {
      type: 'Delegate',
      slots      
    },
  });

lexruntime.postText returns an empty sessionAttributes

Expected behavior lexruntime.postText should return sessionAttributes with data set in Lex's Lambda

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

ajredniwja commented 4 years ago

Hey @plotic Apologies for late reply, I was not able to reproduce this locally, can you make sure you are using the guidelines mentioned here to ship the latest version of the SDK.

github-actions[bot] commented 4 years ago

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.