Sign inSign up

hotelsdotcom/flyte-slack

By hotelsdotcom

Updated almost 6 years ago

A Slack integration pack for Flyte

Image
5

3.2K

hotelsdotcom/flyte-slack repository overview

See https://github.com/HotelsDotCom/flyte-slack license Build Status

flyte-slack

Respond to, and send Slack messages in your Flyte flows.

Quick start

Ensure you are already running Flyte locally (see Quick Start at https://hub.docker.com/r/hotelsdotcom/flyte/ ), then start the pack up:

docker run -d \
   -e FLYTE_API=http://flyte:8080 \
   -e FLYTE_SLACK_TOKEN=xoxp-xxxxx-xxxxx-xxxxx-xxxxx \
   -e FLYTE_SLACK_DEFAULT_JOIN_CHANNEL=A12B34C56 \
   --link flyte:flyte \
   hotelsdotcom/flyte-slack

Now you have the pack running, you can create a simple flow that uses it.

Create the following flow in a local file helloworld.json :

{
    "name": "echo",
    "description": "Echo for debugging",
    "steps": [
        {
            "id": "hello_world",
            "event": {
                "packName": "Slack",
                "name": "ReceivedMessage"
            },
            "criteria": "{{ Event.Payload.message|match:'^flyte hello world$' }}",
            "command": {
                "packName": "Slack",
                "name": "SendMessage",
                "input": {
                    "channelId":"{{ Event.Payload.channelId }}",
                    "message":"You said {{ Event.Payload.message }}"
                }
            }
        }
    ]
}

Then upload this to your local Flyte curl -fsd @helloworld.json http://localhost:8080/v1/flows

If you now enter the Slack channel you specified in FLYTE_SLACK_DEFAULT_JOIN_CHANNEL you should be able to type flyte hello world and get back the response you said flyte hello world.

You can also check the logs from Flyte - you should see confirmation the Slack pack has registered itself with Flyte, your helloworld flow, and that a message was received from Slack and the flow complete with a status of SUCCESS:

[INFO] 2018/04/20 11:26:12 handler.go:47: Pack registered: PackId=Slack
[INFO] 2018/04/20 11:28:17 handler.go:46: Flow flowName=helloworld added to repo
[INFO] 2018/04/20 11:28:30 handler.go:50: Received Event: EventName=ReceivedMessage Pack=&{Id:Slack Name:Slack Labels:map[]}
[INFO] 2018/04/20 11:28:30 flow.go:53: Action has been created actionId=5ad9cededb30a10007748b47
[INFO] 2018/04/20 11:28:32 handler.go:135: Action actionId=5ad9cededb30a10007748b47 taken
[INFO] 2018/04/20 11:28:32 handler.go:81: Received Event: EventName=MessageSent Pack=&{Id:Slack Name:Slack Labels:map[]}
[INFO] 2018/04/20 11:28:32 handler.go:98: Action with actionId=5ad9cededb30a10007748b47 has been completed, new state=SUCCESS

Configuration

The plugin is configured using environment variables:

ENV VARDefaultDescriptionExample
FLYTE_API-The API endpoint to usehttp://localhost:8080
FLYTE_SLACK_TOKEN-The API token to usetoken_abc
FLYTE_SLACK_DEFAULT_JOIN_CHANNEL-A channel to join by default when launched1234
FLYTE_SLACK_BACKUP_DIR$TMPDIRDirectory where to backup joined channels/flyte-slack

Tag summary

Content type

Image

Digest

Size

7.2 MB

Last updated

almost 6 years ago

docker pull hotelsdotcom/flyte-slack