Skip to main content

Slack Integration

Send a notification to a Slack channel when a form is submitted.

Action type: slack Class: Core_Forms\Actions\Slack Source: src/actions/class-slack.php

Setup

  1. Go to api.slack.com/apps and create a new app (or use an existing one).
  2. Enable Incoming Webhooks and create a webhook for the desired channel.
  3. Copy the Webhook URL (starts with https://hooks.slack.com/services/...).
  4. In WordPress, edit your form > Actions tab > Add Action > Send to Slack.
  5. Paste the Webhook URL.

Settings Reference

Setting Required Default Description
Webhook URL Yes -- Slack Incoming Webhook URL
Message No All fields Custom message template. Leave empty to send all fields automatically
Username No Core Forms Bot username displayed in Slack

Internal settings (not shown in UI):

Setting Default Description
icon_emoji :envelope: Emoji icon for the bot avatar
channel -- Override channel (uses webhook default if empty)

Message Variables

Use these variables in the Message field:

  • [all:label] -- all submitted fields as "Label: Value" pairs
  • [NAME] -- value of the "name" field
  • [EMAIL] -- value of the "email" field
  • [any_field_name] -- value of any form field by its name attribute

Auto-Generated Message

When the Message field is left empty, the integration sends all fields formatted as:

*Contact Form* -- New submission
*Name:* Jane Smith
*Email:* jane@example.com
*Message:* I'd like to learn more about your services.

Field names use Slack bold markdown (*text*) and underscores are replaced with spaces.

Example: Custom Message

New lead from [NAME] ([EMAIL])
Company: [company]
Budget: [budget]

[all:label]

Example: Contact Form Notification

  1. Create a form with name, email, and message fields.
  2. Add the Slack action with this message:
:wave: New contact from *[NAME]*
> [message]
Reply to: [EMAIL]

How It Works

  1. On successful submission, the action POSTs a JSON payload to the Slack webhook URL.
  2. If no custom message is set, all fields are formatted with bold labels.
  3. If a custom message is set, cf_replace_data_variables() replaces all [field] placeholders.
  4. The request times out after 15 seconds.
  5. Returns true on success, false if the webhook URL is missing or the request fails.

Troubleshooting

  • Not receiving messages: Verify the webhook URL is correct and the Slack app is still installed in the workspace.
  • Wrong channel: The message goes to the channel configured in the webhook. Create a new webhook for a different channel.
  • Empty fields: Fields that are empty in the submission still appear in the auto-generated message. Use a custom message template to control which fields are included.