Slack messages can contain interactive elements like buttons, dropdowns, radio buttons, and more. This source subscribes to interactive events, like when a button is clicked in a message.
Then this source will be triggered when you or another Slack user in your workspace clicks a button, selects an option or fills out a form.
With this trigger, you can build workflows that perform some work with other APIs or services, and then reply back to the original message.
What this short video to learn how to use this in a workflow, or follow the guide below.
First, if you haven’t already - send yourself a message containing one or more interactive elements. Use the Sending the message with an interactive element guide below to send a messsage containing a button.
If you have already sent a message containing an element, skip to Configuring the source.
Sending the message with an interactive element
The easiest way is to send yourself a message using the Slack - Send Message Using Block Kit action:
)
Then select a Channel you’d like to send the message to, and use the Block Kit Builder to build a message, or just copy the example button blocks below:
Your Slack - Send Message Using Block Kit should look like this:
Configuring the source
By default, this source will listen to all interactive events from your Slack workspace that your connected Slack account has authorization to view.
You can filter these events by selecting a specific channel and/or a specific action_id.
Filtering interactive events by channel
Use the Channels dropdown to search for a specific channel for this source to subscribe to. Only button clicks, dropdown selects, etc. in this selected channel will trigger the source.
Filtering interactive events by action_id
For more specificity, you can filter based on the passed action_id to the message.
The action_id is arbitrary. It’s defined on the initial message sending the button, dropdown, or other interactive element’s markup.
For example, in the section above using the Block Kit to create a message, we defined the button’s action_id as "button_click". But you can choose whichever naming convention you’d like.
If you pass button_click as a required action_id to this source, then only interactivity events with the action_id of "button_click" will trigger this source.
▶
Watch us build a workflow
7 min
Watch now ➜
Trusted by 500,000+ developers from startups to Fortune 500 companies
This is a pre-built, source-available component from Pipedream's GitHub repo. The component is developed by Pipedream and the community, and verified and maintained by Pipedream.
To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.
New Interaction Events on Slack
Description:Emit new events on new Slack [interactivity events](https://api.slack.com/interactivity) sourced from [Block Kit interactive elements](https://api.slack.com/interactivity/components), [Slash commands](https://api.slack.com/interactivity/slash-commands), or [Shortcuts](https://api.slack.com/interactivity/shortcuts).
import common from"../common/base.mjs";exportdefault{name:"New Interaction Events",version:"0.0.9",key:"slack-new-interaction-event-received",description:"Emit new events on new Slack [interactivity events](https://api.slack.com/interactivity) sourced from [Block Kit interactive elements](https://api.slack.com/interactivity/components), [Slash commands](https://api.slack.com/interactivity/slash-commands), or [Shortcuts](https://api.slack.com/interactivity/shortcuts).",type:"source",props:{...common.props,action_ids:{type:"string[]",label:"Action IDs",description:"Filter interaction events by specific `action_id`'s to subscribe for new interaction events. If none selected, all `action_ids` will emit new events.",optional:true,default:[],},conversations:{propDefinition:[
common.props.slack,"conversation",],type:"string[]",label:"Channels",description:"Filter interaction events by one or more channels. If none selected, any interaction event in any channel will emit new events.",optional:true,default:[],},// eslint-disable-next-line pipedream/props-description,pipedream/props-labelslackApphook:{type:"$.interface.apphook",appProp:"slack",/**
* Subscribes to potentially 4 different events:
* `interaction_events` - all interaction events on the authenticated account
* `interaction_events:${action_id}` - all interaction events with a specific given action_id
* `interaction_events:${channel_id}` - all interaction events within a specific channel
* `interaction_events:${channel_id}:${action_id}` - action_id within a specific channel
* @returns string[]
*/asynceventNames(){// start with action_ids, since they can be the most specificconst action_events =this.action_ids.reduce((carry, action_id)=>{// if channels are provided, spread themif(this.conversations &&this.conversations.length >0){return[...carry,...this.conversations.map((channel)=>`interaction_events:${channel}:${action_id}`,),];}return[...carry,`interaction_events:${action_id}`,];},[]);if(action_events.length >0)return action_events;// if no action_ids are specified, move down to channelsconst channel_events =this.conversations.map((channel)=>`interaction_events:${channel}`,);if(channel_events.length >0)return channel_events;// if not specific action_ids or channels are specified, subscribe to all eventsreturn["interaction_events",];},},},methods:{},asyncrun(event){this.$emit({
event,},{summary:`New interaction event${
event?.channel?.id
?` in channel ${event.channel.id}`:""}${
event.actions?.length >0?` from action_ids ${event.actions
.map((action)=> action.action_id).join(", ")}`:""}`,ts: Date.now(),},);},};
Slack uses OAuth authentication. When you connect your Slack account, Pipedream will open a popup window where you can sign into Slack and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Slack API.
Pipedream requests the following authorization scopes when you connect your account:
Slack is a channel-based messaging platform. With Slack, people can work together more effectively, connect all their software tools and services, and find the information they need to do their best work — all within a secure, enterprise-grade environment.