Solmaz Bagherpour
10/16/2025, 4:22 PMMarvin
10/16/2025, 4:22 PMMarvin
10/16/2025, 4:27 PMtext, user_name, channel_id) into an event.
- Create an Automation with an Event trigger that listens for your webhook event.
- Add a Run Deployment action and (optionally) pass parameters using Jinja from the event payload.
- Set your Slack command’s Request URL to the Prefect webhook URL.
Notes:
- Prefect Cloud webhooks + automations are Cloud-only in 2.x; they are not available in self-hosted Server.
- Slack slash commands expect a 200 response within 3s. Prefect’s webhook will return 200, but you won’t get a pretty message back in Slack unless you build that yourself (see option 2). You can still use the Slack response_url from within your flow to post a follow-up message.
- Security: Prefect webhooks do not verify Slack’s signing secret. Treat the webhook URL as a secret and consider filtering in your Automation (e.g., only react if team_id or user_id matches).
- Docs: Webhooks, Automations, Events
Example webhook template idea (maps Slack’s body fields):
{
"event": "slack.command",
"resource": {
"prefect.resource.id": "slack.command.{{ body.command }}",
"user": "{{ body.user_name }}",
"channel": "{{ body.channel_id }}",
"text": "{{ body.text }}"
}
}
Then in the Automation’s Run Deployment action, set parameters like:
{
"prompt": "{{ event.resource.text }}",
"requested_by": "{{ event.resource.user }}"
}
2) Any environment (Cloud or Server): Small HTTP endpoint that calls the Prefect API/Client
- Build a minimal FastAPI/Flask/Lambda endpoint as the Slack command target.
- Verify Slack’s signature and respond quickly (so Slack shows a friendly response).
- From that endpoint, create a flow run via the Prefect client or CLI.
Python (async) client example for 2.x:
import asyncio
from prefect.client.orchestration import get_client
async def trigger_run(deployment_id, params=None):
async with get_client() as client:
fr = await client.create_flow_run_from_deployment(
deployment_id=deployment_id,
parameters=params or {}
)
return fr.id
# asyncio.run(trigger_run("00000000-0000-0000-0000-000000000000", {"name": "world"}))
CLI alternative your service can shell out to:
prefect deployment run "my-flow/my-deployment" -p name=world --watch
Verified command: run prefect deployment run --help shows parameters and usage.
Questions to tailor a concrete setup for you:
- Are you on Prefect Cloud or self-hosted Prefect Server?
- Do you want to pass parameters from the Slack command (via the text input)?
- Do you need a visible Slack confirmation message immediately after the command?