AWS SES
works with Lex
Test Chatbot but after the chatbot is published with Slack app it does not work( doesn't trigger email service). However there does not seem to be any problem with Lambda
function as I am getting the response text back in slack. And i don't think there is a way to check the error why slack is making 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: "[email protected]"
};
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 the issue is that i am not getting the values in [event.currentIntent.slots.Email]
when i publish my Lex
bot on Slack
.
Try to below steps to identify the root cause:
Make sure you have configured your bot with Slack correctly with this step-by-step tutorial.
If your bot works fine in your test bot (inside LEX) but not on Slack make sure you have published the latest version of your bot.
Try this below code 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 this helps.