Skip to content

Instantly share code, notes, and snippets.

@ismaelc
Created April 26, 2020 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismaelc/8071f9f36d72dd63b545a530089ed9c6 to your computer and use it in GitHub Desktop.
Save ismaelc/8071f9f36d72dd63b545a530089ed9c6 to your computer and use it in GitHub Desktop.
var buildReply = async function (msg, token, thread, url) {
var channel = msg.event.channel
// Check if URL exists
if (url.length > 0) {
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
AWS.config.update({
region: 'us-east-1'
})
// Create an SQS service object
var sqs = new AWS.SQS({
apiVersion: '2012-11-05'
})
// Payload for SQS.
var params = {
MessageAttributes: {
"Thread": {
DataType: "String",
StringValue: thread
},
"Channel": {
DataType: "String",
StringValue: channel
},
"URL": {
DataType: "String",
StringValue: url
},
"Token": {
DataType: "String",
StringValue: token
}
},
MessageBody: `Message via SQS from Slack bot`,
QueueUrl: "https://sqs.us-east-1.amazonaws.com/<some number>/summarizer-slack-to-summarizer"
};
// Send the payload to SQS
let sm = await sqs.sendMessage(params).promise();
// Empty reply
reply = ``
}
// No URL, show a help message
else {
reply = 'Type `@tldr` alongside a URL, or as thread to a URL. Direct message works too.'
}
return reply
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment