← Slack + IFTTT integrations

Trigger Event with JSON with IFTTT API on New Mention (Instant) from Slack API

Pipedream makes it easy to connect APIs for IFTTT, Slack and 1000+ other apps remarkably fast.

Trigger workflow on
New Mention (Instant) from the Slack API
Next, do this
Trigger Event with JSON with the IFTTT API
No credit card required
Into to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜

Trusted by 500,000+ developers from startups to Fortune 500 companies

Adyen logo
Brex logo
Carta logo
Checkr logo
Chameleon logo
DevRev logo
LinkedIn logo
Netflix logo
New Relic logo
OnDeck logo
Replicated logo
Scale AI logo
Teamwork logo
Warner Bros. logo
Xendit logo

Developers Pipedream

Getting Started

This integration creates a workflow with a Slack trigger and IFTTT action. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Select this integration
  2. Configure the New Mention (Instant) trigger
    1. Connect your Slack account
    2. Optional- Select one or more Channels
    3. Configure slackApphook
    4. Configure Keyword
    5. Optional- Configure Is Username
    6. Optional- Configure Ignore Bots
  3. Configure the Trigger Event with JSON action
    1. Connect your IFTTT account
    2. Configure Webhook Key
    3. Configure Event Name
    4. Configure JSON Payload
  4. Deploy the workflow
  5. Send a test event to validate your setup
  6. Turn on the trigger

Details

This integration uses pre-built, source-available components from Pipedream's GitHub repo. These components are 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.

Trigger

Description:Emit new event when a username or specific keyword is mentioned in a channel
Version:1.0.11
Key:slack-new-mention

Slack Overview

With the Slack API, you can build all sorts of integrations and applications to
make your work life easier. Here are just a few examples:

  • Automate posting updates to your team channel
  • Create a bot to answer common questions
  • Integrate with your existing tools and services
  • Build a custom dashboard to track your team's progress
  • Create a bot to handle scheduling and meeting requests
  • And much more!

Trigger Code

import common from "../common/base.mjs";
import constants from "../common/constants.mjs";

export default {
  ...common,
  key: "slack-new-mention",
  name: "New Mention (Instant)",
  version: "1.0.11",
  description: "Emit new event when a username or specific keyword is mentioned in a channel",
  type: "source",
  dedupe: "unique",
  props: {
    ...common.props,
    conversations: {
      propDefinition: [
        common.props.slack,
        "conversation",
      ],
      type: "string[]",
      label: "Channels",
      description: "Select one or more channels to monitor for new messages.",
      optional: true,
    },
    // eslint-disable-next-line pipedream/props-description,pipedream/props-label
    slackApphook: {
      type: "$.interface.apphook",
      appProp: "slack",
      async eventNames() {
        return this.conversations || [
          "message",
        ];
      },
    },
    keyword: {
      propDefinition: [
        common.props.slack,
        "keyword",
      ],
    },
    isUsername: {
      propDefinition: [
        common.props.slack,
        "isUsername",
      ],
    },
    ignoreBot: {
      propDefinition: [
        common.props.slack,
        "ignoreBot",
      ],
    },
  },
  hooks: {
    ...common.hooks,
    async deploy() {
      // emit historical events
      const messages = await this.getMatches({
        query: this.keyword,
        sort: "timestamp",
      });
      const filteredMessages = this.conversations?.length > 0
        ? messages.filter((message) => this.conversations.includes(message.channel.id))
        : messages;
      await this.emitHistoricalEvents(filteredMessages.slice(-25).reverse());
    },
  },
  methods: {
    ...common.methods,
    async getMatches(params) {
      return (await this.slack.searchMessages(params)).messages.matches || [];
    },
    async emitHistoricalEvents(messages) {
      for (const message of messages) {
        const event = await this.processEvent({
          ...message,
          subtype: message.subtype || constants.SUBTYPE.PD_HISTORY_MESSAGE,
        });
        if (event) {
          if (!event.client_msg_id) {
            event.pipedream_msg_id = `pd_${Date.now()}_${Math.random().toString(36)
              .substr(2, 10)}`;
          }

          this.$emit(event, {
            id: event.client_msg_id || event.pipedream_msg_id,
            summary: this.getSummary(event),
            ts: event.event_ts || Date.now(),
          });
        }
      }
    },
    getSummary() {
      return "New mention received";
    },
    async processEvent(event) {
      const {
        type: msgType,
        subtype,
        bot_id: botId,
        text,
        blocks = [],
      } = event;
      const [
        {
          elements: [
            { elements = [] } = {},
          ] = [],
        } = {},
      ] = blocks;

      if (msgType !== "message") {
        console.log(`Ignoring event with unexpected type "${msgType}"`);
        return;
      }

      // This source is designed to just emit an event for each new message received.
      // Due to inconsistencies with the shape of message_changed and message_deleted
      // events, we are ignoring them for now. If you want to handle these types of
      // events, feel free to change this code!!
      if (subtype && !constants.ALLOWED_SUBTYPES.includes(subtype)) {
        console.log(`Ignoring message with subtype. "${subtype}"`);
        return;
      }

      if ((this.ignoreBot) && (subtype === constants.SUBTYPE.BOT_MESSAGE || botId)) {
        return;
      }

      let emitEvent = false;
      if (this.isUsername && elements) {
        for (const item of elements) {
          if (item.user_id) {
            const username = await this.getUserName(item.user_id);
            if (username === this.keyword) {
              emitEvent = true;
              break;
            }
          }
        }
      } else if (text.indexOf(this.keyword) !== -1) {
        emitEvent = true;
      } else if (subtype === constants.SUBTYPE.PD_HISTORY_MESSAGE) {
        emitEvent = true;
      }

      if (emitEvent) {
        return event;
      }
    },
  },
};

Trigger Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
SlackslackappThis component uses the Slack app.
N/AnameCache$.service.dbThis component uses $.service.db to maintain state between executions.
Channelsconversationsstring[]Select a value from the drop down menu.
slackApphook$.interface.apphook
Keywordkeywordstring

Keyword to monitor

Is UsernameisUsernameboolean

Filters out mentions of the keyword that are not a username

Ignore BotsignoreBotboolean

Ignore messages from bots

Trigger Authentication

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:

bookmarks:writecalls:readcalls:writechannels:historychannels:readchannels:writednd:readdnd:writeemoji:readfiles:readgroups:historygroups:readgroups:writeim:historyim:readim:writelinks:readlinks:writempim:historympim:readmpim:writepins:readpins:writereactions:readreactions:writereminders:readreminders:writeremote_files:readremote_files:sharestars:readstars:writeteam:readusergroups:readusergroups:writeusers:readusers:read.emailusers:writechat:write:botchat:write:usercommandsfiles:write:userusers.profile:writeusers.profile:readsearch:read

About Slack

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.

Action

Description:Trigger Event with an arbitrary JSON payload. [See docs](https://help.ifttt.com/hc/en-us/articles/115010230347-Webhooks-service-FAQ)
Version:0.0.2
Key:ifttt-trigger-event-with-json

IFTTT Overview

With the IFTTT API, you can build a wide variety of applications and
integrations. Here are just a few examples:

  • A to-do list app that adds new items to a spreadsheet
  • A weather app that sends you a notification when it's going to rain
  • A social media app that posts updates to a blog
  • An e-commerce app that track your order status and sends you shipping updates
  • A fitness app that logs your workout data and shares your progress with
    friends

Action Code

import ifttt from "../../ifttt.app.mjs";

export default {
  name: "Trigger Event with JSON",
  description: "Trigger Event with an arbitrary JSON payload. [See docs](https://help.ifttt.com/hc/en-us/articles/115010230347-Webhooks-service-FAQ)",
  key: "ifttt-trigger-event-with-json",
  version: "0.0.2",
  type: "action",
  props: {
    ifttt,
    webhookKey: {
      propDefinition: [
        ifttt,
        "webhookKey",
      ],
    },
    eventName: {
      propDefinition: [
        ifttt,
        "eventName",
      ],
    },
    data: {
      propDefinition: [
        ifttt,
        "data",
      ],
    },
  },
  async run({ $ }) {
    const response = await this.ifttt.callWebhookWithJSON({
      $,
      webhookKey: this.webhookKey,
      eventName: this.eventName,
      data: this.data,
    });
    $.export("$summary", `Triggered webhook ${this.eventName}`);
    return response;
  },
};

Action Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI.

LabelPropTypeDescription
IFTTTiftttappThis component uses the IFTTT app.
Webhook KeywebhookKeystring

The webhook key obtained in Webhook Settings

Event NameeventNamestring

The event name associated with your applet

JSON Payloaddataobject

A JSON payload to be sent

Action Authentication

IFTTT uses API keys for authentication. When you connect your IFTTT account, Pipedream securely stores the keys so you can easily authenticate to IFTTT APIs in both code and no-code steps.

A request that includes an IFTTT-Service-Key header containing your service key, found in the API tab of the IFTTT Platform under the Service Key heading.

About IFTTT

Every thing works better together

More Ways to Connect IFTTT + Slack

Trigger Event with JSON with IFTTT API on New Message In Channels from Slack API
Slack + IFTTT
 
Try it
Trigger Event with Values with IFTTT API on New Message In Channels from Slack API
Slack + IFTTT
 
Try it
Trigger Event with JSON with IFTTT API on New Direct Message (Instant) from Slack API
Slack + IFTTT
 
Try it
Trigger Event with Values with IFTTT API on New Direct Message (Instant) from Slack API
Slack + IFTTT
 
Try it
Trigger Event with Values with IFTTT API on New Mention (Instant) from Slack API
Slack + IFTTT
 
Try it
New Message In Channels (Instant) from the Slack API

Emit new event when a new message is posted to one or more channels

 
Try it
New Direct Message (Instant) from the Slack API

Emit new event when a message was posted in a direct message channel

 
Try it
New Mention (Instant) from the Slack API

Emit new event when a username or specific keyword is mentioned in a channel

 
Try it
New Reaction Added (Instant) from the Slack API

Emit new event when a member has added an emoji reaction to a message

 
Try it
New Star Added (Instant) from the Slack API

Emit new event when a star is added to an item

 
Try it
Send Message to a Public Channel with the Slack API

Send a message to a public channel and customize the name and avatar of the bot that posts the message. See postMessage or scheduleMessage docs here

 
Try it
Send Message to a Private Channel with the Slack API

Send a message to a private channel and customize the name and avatar of the bot that posts the message. See postMessage or scheduleMessage docs here

 
Try it
Send a Direct Message with the Slack API

Send a direct message to a single user. See postMessage or scheduleMessage docs here

 
Try it
Send Message Using Block Kit with the Slack API

Send a message using Slack's Block Kit UI framework to a channel, group or user. See postMessage or scheduleMessage docs here

 
Try it
Reply to a Message Thread with the Slack API

Send a message as a threaded reply. See postMessage or scheduleMessage docs here

 
Try it