https://github.com/jthomas/goalbot
Serverless Twitter bot which tweets out goals from the 2018 FIFA World Cup
https://github.com/jthomas/goalbot
Last synced: 28 days ago
JSON representation
Serverless Twitter bot which tweets out goals from the 2018 FIFA World Cup
- Host: GitHub
- URL: https://github.com/jthomas/goalbot
- Owner: jthomas
- License: mit
- Created: 2018-06-18T16:50:39.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-27T07:59:15.000Z (almost 8 years ago)
- Last Synced: 2025-03-19T11:06:14.689Z (about 1 year ago)
- Language: JavaScript
- Size: 134 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# World Cup 2018 Goal Bot - 🌍🏆⚽️🤖
Serverless Twitter bot which tweets out goals from the [2018 FIFA World Cup](https://www.fifa.com/worldcup/).
Serverless application built using [IBM Cloud Functions](https://console.bluemix.net/openwhisk/) ([Apache OpenWhisk](https://github.com/apache/incubator-openwhisk)).
Powers the [WC2018 Goals](https://twitter.com/WC2018_Goals) Twitter account.

## architecture
This project has two [serverless functions](https://github.com/apache/incubator-openwhisk/blob/master/docs/actions.md) `goal_tracker` and `twitter`.
`goal_tracker` is connected to an [alarm trigger](https://github.com/apache/incubator-openwhisk-package-alarms) running every sixty seconds. It retrieves all goals for live matches using this [API](http://worldcup.sfg.io/). If new goals are returned, it invokes the `goal` trigger with details.
`twitter` is connected to the `goal` trigger. It takes goal events and sends new tweets using the [Twitter API](https://developer.twitter.com/en/docs/tweets/post-and-engage/overview).
Redis is used to cache goals previously seen by the `goal_tracker` function.
## installation
If you want to deploy this project you will need an instance of the Apache OpenWhisk platform, access to a Redis database and credentials for a Twitter application.
### setup
- Install [The Serverless Framework](https://serverless.com/).
```
npm install serverless
```
- Clone [Git repository](https://github.com/jthomas/goalbot).
```
git clone https://github.com/jthomas/goalbot.git
```
- Install project dependencies.
```
cd goalbot && npm install
```
- Create authentication credential for [Redis](https://compose.com/databases/redis) and [Twitter ](https://apps.twitter.com/) in `creds.json` file.
```json
{
"redis": {
"host": "XXX",
"port": "XXX",
"password": "XXX"
},
"twitter": {
"consumer_key": "XXX",
"consumer_secret": "XXX",
"access_token_key": "XXX",
"access_token_secret": "XXX"
}
}
```
- Run the `deploy` command.
```
serverless deploy
```