Skip to content

pew/cloudflare-workers-slack-bot-link-title

Repository files navigation

Slack Bot to Get Youtube Video Titles

This is an example Cloudflare Workers Slack App/Bot to retrieve titles of shared YouTube links and post them back to the channel. It uses the Slack Events API to listen for and respond to events. This is just a quick and dirty Worker script. Things will probably break when YouTube does a slight change to their site. 🤷

The whole process was a bit confusing, I hope the steps below help you get started.

Cloudflare Part:

  1. Clone this repo
  2. Optionally make adjustments to wrangler.toml to add your own name, domain etc. or just deploy it with npm run deploy
  3. Create the Slack App now to retrieve your OAuth token etc.
  4. Add the OAuth token to your Cloudflare Worker secrets with wrangler secret put slackToken

Slack Part:

  1. Create a new Slack App
  2. Add these features and functionality from the Slack App information page:
    1. Event Subscriptions
    2. Bots
    3. Permissions
  3. Note down the OAuth Token under OAuth & Permissions
  4. Add the following Bot Token Scopes: chat:write and links:read
  5. Add your Cloudflare Workers domain to Event Subscriptions and…
    1. Add link_shared as a Bot User Event
    2. add youtube.com and youtu.be to the App unfurl domains

Resources:

About

Get Titles of Shared YouTube Videos in a Slack Channel

Topics

Resources

Stars

Watchers

Forks