AWS Lambda: SES does not work when Lex Chatbot is published to Slack
AWS SES
works with Lex
Test Chatbot, but after chatbot is published with Slack app it doesn't work (doesn't start email service). However, the problem with the function Lambda
does not occur as I am returning the response text in a weak state. And I don't think there is a way to test the error, why slack is creating the problem.
Lambda
Function:
var aws = require('aws-sdk');
var ses = new aws.SES({
region: 'us-east-1'
});
exports.handler = function(event, context, callback) {
var eParams = {
Destination: {
ToAddresses: [event.currentIntent.slots.Email]
},
Message: {
Body: {
Text: {
Data: "Hi, How are you?"
}
},
Subject: {
Data: "Title"
}
},
Source: "abc@gmail.com"
};
var email = ses.sendEmail(eParams, function(err, data) {
if (err)
else {
context.succeed(event);
}
});
callback(null, {
"dialogAction": {
"type": "ConfirmIntent",
"fulfillmentState": "Fulfilled",
"message": {
"contentType": "PlainText",
"content": "message to convey to the user, i.e. Are you sure you want a large pizza?"
}
}
});
};
Edit 1: I figured out that the problem is that I am not getting the values ββin [event.currentIntent.slots.Email]
when I publish the bot Lex
to Slack
.
source to share
Try the steps below to determine the root cause:
-
Make sure you set up your Slack bot correctly with this step-by-step guide.
/ li> -
If your bot works fine on a test bot (inside LEX) but not on Slack, make sure you have the latest version of your bot published .
-
Try this code below on your AWS Lambda and see what you get in return.
callback(null, { "dialogAction": { "type": "ConfirmIntent", "fulfillmentState": "Fulfilled", "message": { "contentType": "PlainText", "content": "Echo: " + JSON.stringify(event.currentIntent.slots) <-- This } } });
Hope it helps.
source to share
I had a similar problem where the bot was running in lex console but not in a weak state. Although I am not affiliated with email, this is what I discovered.
For some reason, the attributes of an empty session are stored as NULL
if passed to standby. Thus, you cannot add variables to it. You would expect it to be {}
, so if it NULL
changes its value to{}
if(intentRequest.sessionAttributes == null){
intentRequest.sessionAttributes = {};
}
source to share