slack/

directory
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2020 License: Apache-2.0

README

Slack Source for Knative

Slack Source enables integration between slack messages read by a bot users and Knative Eventing.

Deployment

Deploy Knative Slack Source

You can build your own images from source configuring ko and executing with the config folder:

ko apply -f ./config/
Create a Slack Bot User
  1. Customize Slack adding a new clasic bot at https://api.slack.com/apps?new_classic_app=1

    New classic app wizzard

  2. From Basic Information section, display Add features and functionality and select bots, then click on Add Legacy Bot User

    Legacy bot user

  3. Select Install App section and click on Install App to Workspace

    Install to workspace

  4. Copy the bot user OAuth token

    Retrieve token

Creating an Slack Source instance

An instance of the Slack Source is created by creating a manifest at your cluster where it is informed of:

  • The namespace where the instance of the source adapter will run.
  • The kubernetes secret and key that host the bot token copied when configuring the Slack bot.
  • An optional threadiness parameter in case we need more than one thread for sink dispatching.
  • The sink addressable where events will be sent.
apiVersion: sources.triggermesh.io/v1alpha1
kind: SlackSource
metadata:
  name: triggermesh-knbot
  namespace: knative-samples
spec:
  slackToken:
    secretKeyRef:
      name: slack
      key: token
  threadiness: 1
  sink:
    ref:
      apiVersion: serving.knative.dev/v1
      kind: Service
      name: event-display

You can find a full configuration example at the sample folder, replacing the secret's token with your own will make the Slack source ready.

Events

The Slack Source creates a cloud event for each message written at a channel where the bot is added and also to direct messages to the bot.

  • type: com.slack/message
  • source: com.slack.<WORKSPACE>
  • subject: <CHANNEL-WHERE-THE-MESSAGE-WAS-HEARD>
  • data: JSON structure that contains:
   {
     "user_id": "<USER-WRITING-THE-MESSAGE>",
     "text": "<MESSAGE-CONTENTS>"
   }

Directories

Path Synopsis
cmd
adapter command
controller command
pkg
apis/sources/v1alpha1
Package v1alpha1 contains API Schema definitions for the sources v1alpha1 API group +k8s:openapi-gen=true +k8s:deepcopy-gen=package,register +k8s:conversion-gen=knative.dev/eventing-contrib/pkg/apis/sources +k8s:defaulter-gen=TypeMeta +groupName=sources.triggermesh.io
Package v1alpha1 contains API Schema definitions for the sources v1alpha1 API group +k8s:openapi-gen=true +k8s:deepcopy-gen=package,register +k8s:conversion-gen=knative.dev/eventing-contrib/pkg/apis/sources +k8s:defaulter-gen=TypeMeta +groupName=sources.triggermesh.io
client/generated/clientset/internalclientset
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/generated/clientset/internalclientset/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/generated/clientset/internalclientset/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/generated/clientset/internalclientset/typed/sources/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/generated/clientset/internalclientset/typed/sources/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL