Send a Slack message from an Action
What you'll build
A custom trigger and an Action workflow that posts a Slack message when the trigger fires. The action reads the visited URL from the trigger payload and sends it to a Slack incoming webhook.
1. Prerequisites
- A Slack Incoming Webhook URL for the channel you want to notify
- The
SLACK_WEBHOOK_URLenvironment secret set to that webhook URL
2. Create the trigger
Navigate to the Triggers section to create a new trigger. Configure it with the following settings:
- Name: Claude Visit
- Slug:
claude-visit
See Triggers for more information on creating a trigger.
3. Create the action
Navigate to the Actions section to create a new action. Configure it with the following settings:
- Name: Notify Slack on Claude visit
- Trigger: Claude Visit
- Action Retries:
0 - Users: All Users
See Actions for more information on creating an action.
4. Update the workflow
Update the action's workflow to post to Slack when the trigger fires. The webhook URL comes from the SLACK_WEBHOOK_URL environment variable:
const : = async ({ , }) => {
const =
( as { ?: string | null }). ?? "Unknown URL";
await (`${.}`, {
: "POST",
: {
"Content-Type": "application/json",
},
: .({
: "Claude Visit",
: [
{
: "section",
: {
: "mrkdwn",
: `Claude just visited your site.\n\nHere is what they looked at:\n${}`,
},
},
],
}),
});
return { : "success" };
};
export default ;Result
When the Claude Visit trigger fires, the action posts a Slack message with the URL from the trigger payload.
To fire this trigger from a Surface workflow, see Call an action from a workflow.