This library provides an integration with Slack, to support posting messages in your company’s Slack workspace.
Presently, it provides a thin wrapper on the Slack client API chat.postMessage.
To use this integration, you’ll first need to create a Slack App for it.
Create App: Go to https://api.slack.com/apps and click “Create New App”:
Install App: After creating an app, on the left-hand side of the app configuration, click “Bot Users”, and then create a bot user. Then, click “Install App” on the left hand side, and finally “Install App to Workspace”.
Bot Token: Once finished, this will create a new bot token for your bot/workspace:
Copy this bot token and put it somewhere safe; see Safely Storing Credentials for more on this topic.
dagster_slack.
slack_resource
ResourceDefinition[source]¶This resource is for connecting to Slack.
The resource object is a slack.WebClient.
By configuring this Slack resource, you can post messages to Slack from any Dagster solid:
Examples:
import os
from dagster import solid, execute_pipeline, ModeDefinition
from dagster_slack import slack_resource
@solid(required_resource_keys={'slack'})
def slack_solid(context):
context.resources.slack.chat_postMessage(channel='#noise', text=':wave: hey there!')
@pipeline(
mode_defs=[ModeDefinition(resource_defs={'slack': slack_resource})],
)
def slack_pipeline():
slack_solid()
execute_pipeline(
slack_pipeline, {'resources': {'slack': {'config': {'token': os.getenv('SLACK_TOKEN')}}}}
)