I want to use IncomingWebhook api of @slack/client in aws lambda function. There is something problems in my code. Please notice me how can I use.
This is my code below
const { IncomingWebhook } = require('@slack/client');
const config = require('./config')
exports.handler = (event, context, callback) => {
const webhook = new IncomingWebhook(config.slack.webHookUrl)
webhook.send('Hello there', function(err, res) {
if (err) {
console.log('Error:', err);
context.fail('fail')
} else {
console.log('Message sent: ', res);
context.succeed('succeed')
}
});
}
And This is my errors
{
"errorMessage": "RequestId: 9e1b4362-259d-11e8-b422-91108e46ebe1
Process exited before completing request"
}
Here is console errors
START RequestId: 9e1b4362-259d-11e8-b422-91108e46ebe1 Version: $LATEST
2018-03-12T02:32:33.215Z 9e1b4362-259d-11e8-b422-91108e46ebe1 TypeError: Cannot set property 'text' of undefined
at IncomingWebhook.send (/var/task/node_modules/@slack/client/dist/IncomingWebhook.js:26:26)
at exports.handler (/var/task/index.js:6:11)
END RequestId: 9e1b4362-259d-11e8-b422-91108e46ebe1
REPORT RequestId: 9e1b4362-259d-11e8-b422-91108e46ebe1 Duration: 85.31 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 31 MB
RequestId: 9e1b4362-259d-11e8-b422-91108e46ebe1 Process exited before completing request