wskdeploy
The Slack usecase demonstrates how to build an OpenWhisk app to post a sample message to slack every hour using wskdeploy
.
OpenWhisk comes with a Slack package which can be used to post messages to slack. For our app to post hourly messages, we need:
All you have to do is export few environment variables with your slack webhook settings in deployment.yaml
to deploy this app. You can create a new incoming webhook by following step by step instructions from here.
dependencies: slack-package-to-post-messages: location: /whisk.system/slack inputs: username: $SLACK_USERNAME url: $SLACK_URL channel: $SLACK_CHANNEL
Deploy it using wskdeploy
:
wskdeploy -m tests/usecases/slack/manifest.yaml -d tests/usecases/slack/deployment.yaml
$ wsk package get SlackPackage $ wsk package get slack-package-to-post-messages $ wsk trigger get everyhour $ wsk rule get post-to-slack-every-hour
Fire the everyhour
trigger and notice a new message on your slack channel:
Activation: post-to-slack (9909dd5229e84526bff9902a2cd860df) [ "2017-09-12T23:05:17.17872899Z stdout: Hello from WskDeploy!", "2017-09-12T23:05:17.549177677Z stdout: Posted message to slack" ]