Created
February 28, 2019 23:42
-
-
Save maciejmatu/298050a2a3844c143e9073d7cb93b15d to your computer and use it in GitHub Desktop.
Simple server-less slack webtask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { WebClient } = require('@slack/client'); | |
const fetch = require("node-fetch"); | |
const API_URL = 'http://ron-swanson-quotes.herokuapp.com/v2/quotes'; | |
const CHANNEL_ID = 'D6X9SM885'; | |
module.exports = async (context, cb) => { | |
const [quote] = await fetch(API_URL).then(res => res.json()); | |
const { chat } = new WebClient(context.secrets.SLACK_TOKEN); | |
const res = await chat.postMessage({ | |
channel: CHANNEL_ID, | |
text: `Ron swanson quote for the day: \n*${quote}*` | |
}); | |
return cb(null, { message: res.ts }); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment