Code Monkey home page Code Monkey logo

vidbot's Introduction

Vidbot

A mashup of Slack RTM, YouTube and Google PubSubHubbub

Vidbot connects YouTube push notifications with your Slack team using a combination of the YouTube Push Notifications API, the YouTube Data API v3 and the Slack Real Time Messaging API. Subscriptions are managed by sending text commands to Vidbot on Slack.

Contents

Installation

Installing the subscriber and notifier microservices

First, we need to install the subscriber and notifier microservices. Follow the steps in both the subscriber/ and notifier/ directories.

1. Install the npm dependencies
npm install
2. Deploy to AWS Lambda with Claudia.js

Ensure your AWS credentials are stored in ~/.aws/credentials (see here for more info).

Deploy to Lambda by running:

claudia create --handler lambda.handler --deploy-proxy-api --region us-east-1

(You can customise the region as needed.)

You should see an output like this:

{
  "FunctionName": "slackyoutube-subscriber",
  "FunctionArn": "arn:aws:lambda:us-east-1:930066526813:function:slackyoutube-subscriber:2",
  "Runtime": "nodejs4.3",
  "Role": "arn:aws:iam::930066526813:role/slackyoutube-subscriber-executor",
  "Handler": "lambda.handler",
  "CodeSize": 3654028,
  "Description": "YouTube Slack subscriber microservice",
  "Timeout": 10,
  "MemorySize": 128,
  "LastModified": "2017-02-15T19:27:16.459+0000",
  "CodeSha256": "IB/7cWA0aIOHx0mkpXfFwK7/0iqoElpF47k4Ls/1gHU=",
  "Version": "2",
  "VpcConfig": {
    "SubnetIds": [],
    "SecurityGroupIds": [],
    "VpcId": null
  },
  "KMSKeyArn": null,
  "url": "https://ot3nt0vg0h.execute-api.us-east-1.amazonaws.com/latest"
}

Make a note of the url above.

Installing the Slack chatbot

You can host the chatbot on any platform that supports Node + websockets, but BeepBoop is pre-configured to work "out of the box".

1. Signup to BeebBoop

At https://beepboophq.com/. The free plan works fine ๐Ÿ˜!

2. Push the slackbot/ directory to a separate repository

BeebBoop needs the root directory of the chatbot to be its own repository. You can grab just the chatbot part of the app here: https://github.com/alexpeattie/slackyoutube-slackbot

3. Install the bot

Create a New Project on BeebBoop and follow the prompts.

4. Configure the bot

Set the SUBSCRIBER_SERVICE_URL config variable to the url value you took from Claudia.js's output above when deploying the subscriber microservice.

Configuring the microservices

Lastly, you'll need to add the following environment variables to the microservices on Lamdba. Add environment variables from Functions โ†’ your-function โ†’ Code.

Subscriber microservice
  • YT_API_KEY - API key to access the YouTube Data API v3
  • NOTIFIER_SERVICE_URL - The URL of your notifier microservice
Subscriber microservice
  • BEEPBOOP_ID - The project ID of your BeebBoop project (shown in pink below)

Usage

You can ask the bot to setup a subscription by saying:

@vidbot subscribe to zoella280390

"zoella280390" can be replaced with any YouTube username or channel UID (e.g. UCWRV5AVOlKJR1Flvgt310Cw). Vanity URLs currently aren't supported. Notifications will be sent to the channel from which you ping @vidbot.

You can unsubscribe by saying:

@vidbot unsubscribe from zoella280390

Dependencies

The project makes use of the following dependencies:

  • Botkit - used to build the Slack chatbot
  • Express.js - to provide the HTTP interfaces for the services
  • Claudia.js - for easy deployment to Lambda
  • aws-serverless-express - to expose the Express endpoints to Lambda
  • Docker - for packaging the chatbot for deployment to BeepBoop
  • Google APIs Node.js Client - for connecting to the YouTube Data API
  • Bluebird - for "promisifying" Google API calls
  • request - for passing requests between services, and setting up PubSubHubbub subscriptions
  • xml2js and body-parser - to parse the the XML feed updates (from push notifications)
  • moment - to calculate the difference between published time and updated time (used to decide if the change is a new or updated video)

License

Nitlink is released under the MIT license. (See License.md)

Author

Alex Peattie / alexpeattie.com / @alexpeattie

vidbot's People

Contributors

alexpeattie avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.