This is a netlify function for a Slackbot that queries the CKAN API of Berlin's data portal for new datasets and for updated datasets. It's written in TypeScript, using the Bolt JS framework. It can be triggered via specific keywords in Slack messages. Also, it responds to the slash command /opendata [number of days] and then displays the new and updated records for the queried number of days.
- Run
npm install
to install all node dependencies. - Install Netlify CLI globally using the command
npm install netlify-dev -g
. - To run this function locally, you'll need to link your Netlify site with your repository. Easiest way is to create a
.netlify
folder and inside that, create astate.json
file with the following contents. Get your site id or API id from the site settings and paste it here. Then run the commandnetlify link
.
{
"siteId": "PASTE YOUR API ID HERE"
}
- Run
netlify build
to build your code and generate a function. This command uses the settings in thenetlify.toml
file to run a build command. The build command compiles TypeScript files into JavaScript and automatically creates the requirednetlify/functions
folder for you and places theindex.js
function file inside this folder. - Run
netlify dev
to start a local development server to test your function. If the local server starts at port 8888, then the URL to access this function ishttp://localhost:8888/.netlify/functions/index
.
There are several steps necessary to get the Slackbot running.
- deploy the function to netlify
- integrate Slack by creating a Slack app, grabbing the credentials and integrating it into the function so that the function can communicate with the Slack app
- configure the slack app to subscribe to events and to implement the slash command
All this steps are described in the Medium article "Creating a Slack Bot Using Netlify Functions" by Clyde D'Souza. You can follow the tutorial to get the app running and to deploy it.
Before you create a pull request, write an issue so we can discuss your changes.
Thanks goes to these wonderful people (emoji key):
Lisa-Stubert 📖 💻 🤔 |
Fabian Morón Zirfas 🧑🏫 |
This project follows the all-contributors specification. Contributions of any kind welcome!
|
Together with:
|
A project by:
|
Supported by:
|