Skip to main content

Event Actions

Slack Connector

Building and Pushing the Image

Prerequisites

Staging

  • Download the slack connector image by running: (or follow repo instructions to build the image w/ Docker)
    • curl -O https://publicimages.s3.us-east.cloud-object-storage.appdomain.cloud/slack-connector-ibm.tar.gz
  • For the following steps, refer to Pushing a Docker Image (Amazon) as needed
  • Stage the image in your environment. One way to do this is Using docker & aws cli:
    • docker import /path/to/exampleimage.tgz`
    • Retreive an authentication token & authenticate the docker client to your registry
      • aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com`
    • If you haven't already, create a repository in Amazon ECR:
      • aws ecr create-repository \
        --repository-name my-repository \
        --image-scanning-configuration scanOnPush=true \
        --region region
    • Tag your image with the Amazon ECR registry
      • docker tag <local-image-id> aws_account_id.dkr.ecr.us-west-2.amazonaws.com/my-repository:tag
    • Push the image
      •  docker push aws_account_id.dkr.ecr.us-west-2.amazonaws.com/my-repository:tag

Configure Slack App, Environment Variables

Slack Setup

  • Navigate to create a new app
  • Once the app is created, open it (click on it) and go to Incoming Webhooks
    • Activate incoming webhooks:
    • Add one to your workspace:
  • Navigate to OAuth & Permissions
    • Copy the Bot User OAuth Token
  • On the same page, add OAuth scopes for incoming-webhook, chat:write and channels:read
  • Go to your slack channel and invite the bot to it:
    • /invite @BOT_NAME

Environment Variables

  • The yaml files are found under the k8s folder of your project directory
    • secret.yaml
      • paste the bot token into SLACK.TOKEN
        • ex: SLACK.TOKEN: "xoxb-..." (redacted)
      • Ensure the channel name (SLACK.CHANNEL) matches with what you have in Slack
    • deployment.yaml
      • ensure the image points to the image location in ecr:
        - name: slack-connector
        image: >-
        748107796891.dkr.ecr.us-east-1.amazonaws.com/slack-connector:latest
        ports:
        - name: http
        containerPort: 8080
        protocol: TCP
    • service.yaml
      • ensure the ports section is consistent with deployment.yaml and that all names match
  • update the configuration by running kubectl apply -f k8s/<>.yaml for each of the yaml files
  • use the updated configuration by deleting the pod
    • run kubectl get pod and not the slack connector pod name
    • run kubectl delete pod <slack-connector-pod-name>
    • the pod will be brought back with the newly applied config

Installing Event-Driven External Service Extensinons

  • Insall addon 5.5.4 Event-Driven External Service Invocation Extensions

Create Event and Subscription

  • From the ACCE Console, select and Object Store and navigate to Events, Actions, Processes -> Event Actions and create a new Event Action

  • Give it a name of your choice and under Event Action Type Selection, select Webhook
  • Under Webhook Configurations:
    • set External Event Receiver URL to be http://<image-name>:<port>/slack
      • ex: http://slack-connector:8080/slack
    • set External Event Receiver Registration Identifier to be any name
  • Click Finish to Create the new Event
  • Under Data Design -> Classes -> Document, click on Actions -> New Class
    • Enter any names you would like and proceed through the final screen (click Finish)
  • Navigate to Subscriptions (also under Events, Actions, Processes) and create a New Subscription
    • Under Select Classes, choose Document for the Class Type and your newly created class for the Class
    • For Scope, choose the Applies to all objects of this class
    • Under Select the Triggers, select Creation Event and Update Event
    • Under Select an Event Action, choose the Event Action you created in the previous step
    • Choose default options for the rest and click Finish

Test the App (Trigger Event Action)

  • To Trigger the Event Action, Navigate to Browse -> Root Folder & create a new document
  • Under Define New Document Objects, be sure to select your newly created subclass for the Class
  • Select any other options as you wish and click Finish to create the document
  • Under the Root Folder -> Content, select your newly created document
  • Click on Properties and modify one of them, for example, Document Title:
  • Open your Slack Channel. You should see the bot posting about the triggered Webhook: