Skip to content

ahuglajbclajep/slack-tweet-command

Repository files navigation

slack-tweet-command

Add the /tweet command to your Slack workspace. It runs on Cloudflare Workers, so there is no cold starts.

Usage

  • /tweet message
    Tweet your message. The message will be posted correctly even if it contains line breaks or URLs.

Install

1. Deploy to Cloudflare

Deploy to Cloudflare Workers

or

$ git clone https://github.com/ahuglajbclajep/slack-tweet-command.git .
$ yarn
$ npx wrangler login
$ npx wrangler whoami
# enter the Account ID in the account_id field of wrangler.toml
$ yarn deploy

2. Apply for a twitter developer account

Authentication is required to tweet from third party clients.

  1. Apply for a developer account from here
  2. Create an app
  3. Note down API Key, API Secret, Access Token and Access Secret

3. Create a Slack app

Go to the your Slack apps page.

  1. Create New App
    • Development Slack Workspace: select a workspace you want to install this app
  2. Create New Slash Command
    • Request URL: your Worker's URL
  3. Note down Signing Secret

4. Set environment variables

$ npx wrangler secret put SLACK_SIGNING_SECRET    # enter the Slack Signing Secret
$ npx wrangler secret put TWITTER_CONSUMER_KEY    # enter the Twitter API Key
$ npx wrangler secret put TWITTER_CONSUMER_SECRET # enter the Twitter API Secret
$ npx wrangler secret put TWITTER_ACCESS_TOKEN    # enter the Twitter Access Token
$ npx wrangler secret put TWITTER_ACCESS_SECRET   # enter the Twitter Access Secret

License

MIT