How to run SlackTask using EnvVarSecret
See original GitHub issueI’m trying to send a slack message using prefect.tasks.notifications.slack_task.SlackTask
and prefect.tasks.secrets.EnvVarSecret
to post to Slack.
from prefect import task, Flow
from prefect.tasks.secrets import EnvVarSecret
from prefect.tasks.notifications.slack_task import SlackTask
@task
def notify_slack():
slack_secret = EnvVarSecret('SLACK_WEBHOOK_URL')
task = SlackTask(webhook_secret=slack_secret)
task.run(message='Test slack message')
with Flow('slack test') as slack_flow:
result = notify_slack()
slack_flow.run()
This throws this exception
ValueError: Local Secret "<Task: SLACK_WEBHOOK_URL>" was not found.
The environment variable SLACK_WEBHOOK_URL has a valid value in it.
How can I use SlackTask
and EnvVarSecret
to successfully send a message to slack?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
How to send Slack notifications using the SlackTask
1. Create a slack webhook First, to create a webhook, go to Slack API: Applications | Slack → Create a New App →...
Read more >Expose build ENV variables to tasks · Issue #494 - GitHub
Hi there! We use Pivotal Tracker to provide visibility into what our team is working on. A story for this issue has been...
Read more >Make your Slack app accessible directly from a message
Enter an App Name and select your development workspace, then click the Create App button. ... Next, at Basic Information, scroll down to...
Read more >Workflow Builder Steps from Apps - Slack API
Now, go to Features > App Home. Make sure the Home Tab is checked. This app will update the user's app home with...
Read more >Hello World, Bolt ⚡️ - Building your very first app with Bolt
Once you create, at Settings > Basic Information screen, scroll down to App Credentials, and find your Signing secret by clicking Show to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah @petermorrow my bad. The
SlackTask
needs to be instantiated before it’s called so you could do something like one of the two options below:Also, glad you have it working with a custom task! 😄
That did the trick, thanks @joshmeek!