参考: AWS Lambda でS3 にファイルをアップロードしたらSlackチャットに通知するやつ
元記事では Slack だったけど、typetalk も業務でお世話になってるので、Typetalk 対応もしてみた。
Typetalk API
const TYPETALK_TOKEN = "...."; var req = require('request'); exports.handler = function(event, context) { var filename = event.Records[0].s3.object.key; typetalk(TYPETALK_TOKEN, "your typetalk toppick id", "Put: "+filename); }; function typetalk(token, topic_id, message) { req.post('https://typetalk.in/api/v1/topics/'+topic_id+'?typetalkToken='+token) .form({ message: message }) .on('response', function (response) { response.on('data', function(data) { context.done(null, data); }); }) .on('error', function (err) { cotext.done(err, 'Failed post the chat'); }); }
https://github.com/wokamoto/aws-lambda-samples/tree/master/s3slack
コメントを残す