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.
First, we need to install the subscriber and notifier microservices. Follow the steps in both the subscriber/
and notifier/
directories.
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.
You can host the chatbot on any platform that supports Node + websockets, but BeepBoop is pre-configured to work "out of the box".
At https://beepboophq.com/. The free plan works fine ๐!
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
Create a New Project on BeebBoop and follow the prompts.
Set the SUBSCRIBER_SERVICE_URL
config variable to the url
value you took from Claudia.js's output above when deploying the subscriber microservice.
Lastly, you'll need to add the following environment variables to the microservices on Lamdba. Add environment variables from Functions โ your-function โ Code.
YT_API_KEY
- API key to access the YouTube Data API v3NOTIFIER_SERVICE_URL
- The URL of your notifier microservice
BEEPBOOP_ID
- The project ID of your BeebBoop project (shown in pink below)
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
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)
Nitlink is released under the MIT license. (See License.md)
Alex Peattie / alexpeattie.com / @alexpeattie