Hello, I'm botnyan. Outgoing-webhook slackbot collaborates with Google Drive documents 🐱
This is Outgoing-webhook slackbot collaborates with Google Drive documents 🐱
Here is one of working screenshot:
- botnyan has pairs of keyword and Google Drive document ID.
- If user says some keyword (in this case, I just said "パチン"), botnyan retrieves document contents from Google Drive corresponding to the keyword, then replies it :)
- botnyan will repond only if message fully match the keyword, because we do not want the unnecessary reation to some messages.
You can install this on heroku instance.
First, please install these packages.
- Git
- Heroku toolbelt
- OpenSSL
-
Create new application on your heroku dashboard.
-
Clone this code on your machine.
git clone [email protected]:supistar/Botnyan.git
- Configure document settings
- You can configure pairs of keyword and Google Drive document ID. For details, please see
settings.py
on project root directory. They hasKeyword
andDocumentID
elements.- Keyword : Specify keyword to respond. You can specify keyword(s) by string or list.
- DocumentID : Specify document ID of Google Drive. ID is placed on
https://docs.google.com/document/d/{DocumentID}
.
- Commit the changes of
settings.py
- This changes are used by heroku deployment, no need to push it on GitHub :)
git add -u .
git commit -m "Customize settings.py"
- Add heroku configuration to current project
heroku git:remote -a ${HerokuAppName}`
- Deploy your application
git push heroku master
- Create a Google Service Account
- Visit the Google Developer Console
- Create new project or select existing your project.
- Click
APIs & Auth
->Credentials
- Click
Create new Client ID
- Create a
Service account
withP12 Key
key type. - Retrieve p12 file after account creation.
- Check your service account's
EMAIL ADDRESS
(This value will be used in subsequent step)
- Incorporate Service account private key
cd path/to/p12directory
openssl pkcs12 -passin pass:notasecret -in privatekey.p12 -nocerts -passout pass:notasecret -out key.pem
openssl pkcs8 -nocrypt -in key.pem -passin pass:notasecret -topk8 -out google-services-private-key.pem
rm key.pem
- Configure
Config Variables
heroku config:add SLACK_WEBHOOK_TOKEN=ExampleOfTokenValue
heroku config:add GOOGLE_OWNER_EMAIL=*****@gmail.com
heroku config:add GOOGLE_CLIENT_EMAIL=******************@developer.gserviceaccount.com
heroku config:add GOOGLE_PRIVATE_KEY=`cat path/to/p12directory/google-services-private-key.pem`
heroku config:add BOTNYAN_BASE_URL=https://mybotnyan.herokuapp.com
- Run your botnyan
heroku ps:scale web=1
- Open Outgoing WebHooks (https://yourteam.slack.com/services/new/outgoing-webhook)
- Click
Add Outgoing WebHooks Integration
- Configure Integration settings
- Trigger Word(s): Specify some keywords defined in your
settings.py
- URL(s): Specify
https://mybotnyan.herokuapp.com/api/slack/webhook
- botnyan will respond to the public channel messages, not private channel. This limitation come from slack specification.