Giter Club home page Giter Club logo

flyte-slack's Introduction

flyte-slack

Build Status Docker Stars Docker Pulls

A Slack pack for flyte.

Build

Pack requires go version min. 1.11

  • go build go build
  • go test go test ./...
  • docker build docker build -t <name>:<version> .

Configuration

This plugin only works with classic Slack apps at the moment. To learn how to create one, click here.

The plugin is configured using environment variables:

ENV VAR Default Description Example
FLYTE_API - The API endpoint to use http://localhost:8080
FLYTE_SLACK_TOKEN - The Slack Bot API token to use token_abc

Example FLYTE_API=http://localhost:8080 FLYTE_SLACK_TOKEN=token_abc ./flyte-slack

Commands

All the events have the same fields as the command input plus error (in case of failed event)

SendMessage

{
    "message": "...", // required
    "channelId": "...", // required
    "threadTimestamp": "..." // optional
}

Returned events

MessageSent

{
    "message": "...",
    "channelId": "...",
    "threadTimestamp": "..."
}

SendMessageFailed

{
    "message": "...",
    "channelId": "...",
    "error": "..."
}

SendRichMessage

See the Slack message formatting API (and the example below) for details on what can be included in this. All of the fields (at the time of writing) available on the Slack API are supported here.

Returned events

RichMessageSent

The returned event payload is the same as the input.

SendRichMessageFailed

{
  "inputMessage": { ... },
  "error": "..."
}

Events

ReceivedMessage

{
    "channelId": "...",
    "user": {                // user that sent the message
        "id": "...",
        "name": "...",       // display name
        "email": "...",
        "title": "...",      // e.g. Principal Systems Engineer
        "firstName": "...",
        "lastName": "...",
        "timestamp": "...",
        "threadTimestamp": "..."
    },
    "message": "..."
}

ReactionAdded

{
    "type":"...",
    "user":"...",  //user that adds the reaction
    "itemUser":"...",  //user that writes the message, file etc.
    "item": {
            "type" :"message", 
            "channel" :"...", 
            "timestamp" :"..."
            }, 
    "reaction" :"...", //value of the reaction
    "eventTimestamp" :"..." 
}

Example Flows

The following flow will allow you to type any message into a Slack channel where this pack is listening and have it echo back whatever you say. E.g.: typing echo hello world will echo "hello world" back to you.

{
  "name": "echo",
  "description": "Echo message back to the sender with a mention, like echo service",
  "steps": [
    {
      "id": "get_message",
      "event": {
        "packName": "Slack",
        "name": "ReceivedMessage"
      },
      "criteria": "{{ Event.Payload.message | match: '^echo\\\\s+' }}",
      "context": {
        "Msg": "{{ Event.Payload.message | slice:'5:'}}",
        "Channel": "{{ Event.Payload.channelId }}",
        "RequestorId": "{{ Event.Payload.user.id }}"
      },
      "command": {
        "packName": "Slack",
        "name": "SendMessage",
        "input": {
          "channelId":"{{ Context.Channel }}",
          "message":"<@{{ Context.RequestorId }}>, you said:\n>>> {{ Context.Msg }}"
        }
      }
    }
  ]
}

This flow sends a rich message for a hypothetical deployment. More information about rich messages can be found in the Slack API documentation. The message format is exactly the same as documented (at least currently!) so can be directly cut & pasted into Slack's message builder tool, e.g.: this is the below message, verbatim in the tool

{
  "name": "announce_deployments",
  "description": "Announces deployments",
  "steps": [
    {
      "id": "on_deployment_success",
      "event": {
        "packName": "MyContinuousDeploymentToolPack",
        "name": "DeploymentSucceeded"
      },
      "command": {
        "packName": "Slack",
        "name": "SendRichMessage",
        "input": {
          "channel": "ABCDEFG",
          "attachments": [
            {
              "fallback": "The deploy of `YOURAPP.0.1.641` to `staging` has completed with a status of *success*.",
              "color": "#36a64f",
              "title": "Deployment Update",
              "text": "<@USER>, the deploy of `YOURAPP.0.1.641` to `staging` has completed with a status of *success*.",
              "fields": [
                {
                  "title": "Artefact",
                  "value": "YOURAPP.0.1.641",
                  "short": true
                },
                {
                  "title": "Environment",
                  "value": "staging",
                  "short": true
                }
              ],
              "actions": [
                {
                  "type": "button",
                  "text": "View Logs",
                  "url": "http://logs.example.com/staging/deploy/vFZhU-1388",
                  "style": "primary"
                }
              ]
            }
          ]
        }
      }
    }
  ]
}

flyte-slack's People

Contributors

andrei-trandafir avatar balazs-fark-epam avatar dangorst1066 avatar dvdthms avatar fooksca avatar isaacasensio avatar jfong99 avatar jollinshead avatar osipex avatar pamelin avatar rityagi173 avatar songupta7 avatar ukjasonwright avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.