<@ULVA73B9P> What do my headers need to look like ...
# marvin-ai
c
@Marvin What do my headers need to look like to send a slack notification within my "Call webhook block"?
m
thought for 74.3 seconds
If you're sending to a Slack incoming webhook from a Prefect
Webhook
block /
Call webhook
action, your headers should usually be:
Copy code
Content-Type: application/json
And that's typically it. A few important details: Slack does not need an Authorization header for incoming webhooks. The secret is embedded in the webhook URL itself. So in your Prefect
Webhook
block, headers can be either:
Copy code
{
  "Content-Type": "application/json"
}
or possibly empty if you're calling the block directly with a Python
dict
payload. But if you're using the Call webhook automation action, the payload is rendered as a string, so it's safest to set:
Copy code
{
  "Content-Type": "application/json"
}
Example Slack payload body:
Copy code
{
  "text": "Hello from Prefect"
}
So your setup should look roughly like: URL
Copy code
<https://hooks.slack.com/services/>...
Method
Copy code
POST
Headers
Copy code
{
  "Content-Type": "application/json"
}
Payload
Copy code
{
  "text": "Flow run failed"
}
Gotcha: make sure the payload is valid JSON, especially if you use Jinja templating in the
Call webhook
action. Example:
Copy code
{
  "text": "Flow {{ flow_run.name }} failed"
}
If you want, I can also show you the exact
Call webhook
payload template to use for a Slack message in a Prefect automation. Relevant docs: - Events and automations - Slack incoming webhooks