Lädt...


🔧 How to create a Slack workflow with webhooks in Momento Topics


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Have you ever heard of Slack? It’s this niche, up-and-coming communication platform that’s really starting to gain traction in the workplace. 😉‍

Okay, but really, Slack is everywhere. We all know it. Many organizations are even dropping email in favor of Slack—for internal and external comms. But the real power of Slack isn’t in channels, threads, or DMs—it’s their Workflow Builder. This tool turns Slack into an integration machine, letting you tackle almost any task with just some minor configuration and API connections.‍

In this blog post, we'll show how simple it is to use webhooks in Momento Topics to create a seamless Slack workflow that sends a message whenever an event is published to a topic. With that in place, you can easily extend the workflow in any number of ways—from task automation to alerts to chat monitoring. Let’s dive in.‍

How to build a Slack workflow

First, select the Slack workspace in which you want the workflow to live. Then, navigate to the Workflow Builder.

Screenshot of where the Workflow Builder is in Slack

Click on Create Workflow.

Screenshot of the create workflow button in the workflow builder

Select From a webhook.

Screenshot of the workflow builder with the start from scratch menu

Click on the Set Up Variables button and add variables for token_id and text.

Dynamic variables configured in the workflow

At the bottom of this window, copy the URL from the Web request URL field and save it for later.

Screenshot of where to copy the link of your webhook

Type “send” in the search bar and click on Send a message to a channel.

Screenshot of the action to send a message to a channel

Click the pencil icon to configure the message that gets sent to Slack. We’ll use the variables we set up earlier to show who sent the message and what they said. When you’re done, hit the Save button.

Screenshot of the message to post in slack

On the main workflow screen, click the Publish button and give your workflow a name and meaningful description. Hit Next to publish your workflow.

Screenshot of the publish dialog for a workflow

Create a webhook in Momento Console

Navigate to Momento Console and create a cache if you don’t already have one.

Screenshot of the cache configuration in Momento

Navigate to your new cache and click on the Webhooks menu option on the left.

Screenshot showing where the webhooks menu item is in Momento

Click the Create Webhook button and fill out the form by providing a name for your webhook, which topic it should trigger on, and the value you copied from the Slack workflow. Then hit Create.

Screenshot showing the webhook configuration fields

Now that we have our webhook created and our workflow published, let’s test it out! Go to the Topics page in Momento Console and select the cache and topic name we just configured, then hit Subscribe.

Screenshot showing the topics dashboard

In the “Publish messages” section, type in your message and hit Publish.

Screenshot showing a test message being sent in Momento

Zip on over to Slack and check out your new message!

Screenshot of a slack message with part of the data missing

Add username to the messages

Now you might notice there is no username displaying to the left of the colon. That’s because we published a message without using an auth token with an embedded identifier. In a real world scenario, all our messages would uniquely identify a user. So let’s try that out.‍

I wrote this small script using the Momento JavaScript SDK to create a short-lived token scoped to publish only to our slack-bot topic. This token has my username embedded in it so it should show up in our Slack channel when we publish a message.


const { AuthClient, Configurations, CredentialProvider, TopicClient, ExpiresIn } = require('@gomomento/sdk');
const dotenv = require('dotenv');
dotenv.config();

const USERNAME = 'allen';
const MESSAGE = 'It worked - yeehaw!';

const publishMessage = async () => {
  const authClient = new AuthClient({
    credentialProvider: CredentialProvider.fromEnvironmentVariable({ environmentVariableName: 'MOMENTO_API_KEY' })
  });

  const tokenScope = {
    permissions: [
      {
        role: 'publishonly',
        cache: 'slack',
        topic: 'slack-bot'
      }
    ]
  };

  const token = await authClient.generateDisposableToken(tokenScope, ExpiresIn.minutes(1), { tokenId: USERNAME });

  const topicClient = new TopicClient({
    configuration: Configurations.Laptop.v1(),
    credentialProvider: CredentialProvider.fromString({ authToken: token.authToken })
  });

  topicClient.publish('slack', 'slack-bot', MESSAGE);
};

publishMessage();

After I run this script, I get a message in Slack with my username and message!

Screenshot of a slack message with username included

Super cool and super easy! After you do it once, this integration only takes a few minutes to set up. Plus, Slack workflows are incredibly easy to extend, so you could even set it up to send a message back over a topic! More on that in another post. 🙂‍

You can use this integration for alerts, status updates, monitoring chat sessions, and much, much more. We’re super excited about webhook functionality in Momento Topics and further enabling you to build the best developer experience for your users and development teams!‍

So what are you waiting for? Go out there and build!

Happy coding!

...

🔧 How to create a Slack workflow with webhooks in Momento Topics


📈 92.57 Punkte
🔧 Programmierung

🔧 Live Streaming from Unity - Adding Real-Time Interactions with Momento Topics


📈 43.3 Punkte
🔧 Programmierung

🔧 🎣 Webhooks 101 - How I use Discord Webhooks for personal notifications


📈 39.41 Punkte
🔧 Programmierung

🔧 Understanding Webhooks: The Slack Notification System


📈 30.55 Punkte
🔧 Programmierung

🔧 Step-by-Step Guide on How to Send Error Messages from Laravel App to Slack Using Webhooks


📈 30.55 Punkte
🔧 Programmierung

📰 Expert Insight On Slack Phishing Attacks Using Webhooks


📈 30.55 Punkte
📰 IT Security Nachrichten

📰 Slack phishing attacks using webhooks


📈 30.55 Punkte
📰 IT Security Nachrichten

🔧 Momento added as an Amazon EventBridge API destination!


📈 27.49 Punkte
🔧 Programmierung

🔧 Momento Migrates Object Cache as a Service to Ampere Altra


📈 27.49 Punkte
🔧 Programmierung

🔧 Strong Performance with EC2, Lambda, and the Momento SDK for Rust


📈 27.49 Punkte
🔧 Programmierung

🔧 Mind Boggling Speed when Caching with Momento and Rust


📈 27.49 Punkte
🔧 Programmierung

📰 “Tecnológicamente vivimos un momento sin parangón”


📈 27.49 Punkte
📰 IT Security Nachrichten

📰 I difensori si riuniscono: è il momento di scendere in campo


📈 27.49 Punkte
📰 IT Security Nachrichten

🍏 Momento für Mac und iOS-Geräte heute kostenlos


📈 27.49 Punkte
🍏 iOS / Mac OS

📰 5 modi in cui i CIO possono aiutare l’IA generativa a raggiungere il suo momento di gloria


📈 27.49 Punkte
📰 IT Security Nachrichten

🔧 How to Cache Expensive Database Queries Using the Momento Serverless Cache


📈 27.49 Punkte
🔧 Programmierung

🔧 Understanding Workflow Schemes and Instances in Optimajet Workflow Engine


📈 23.56 Punkte
🔧 Programmierung

🕵️ CVE-2020-2753 | Oracle Workflow up to 12.2.9 Workflow Notification Mailer unknown vulnerability


📈 23.56 Punkte
🕵️ Sicherheitslücken

🔧 What is Workflow Automation? The Essence and Evolution of Workflow Automation


📈 23.56 Punkte
🔧 Programmierung

📰 Git Workflow for Machine Learning Projects: the Git Workflow I use in my Projects


📈 23.56 Punkte
🔧 AI Nachrichten

🕵️ CVE-2023-36486 | ILIAS up to 7.22/8.2 workflow-engine behavioral workflow


📈 23.56 Punkte
🕵️ Sicherheitslücken

🕵️ CVE-2023-36485 | ILIAS up to 7.22/8.2 workflow-engine behavioral workflow


📈 23.56 Punkte
🕵️ Sicherheitslücken

🕵️ JetBrains YouTrack prior 2020.3.7955 Workflow Rule behavioral workflow


📈 23.56 Punkte
🕵️ Sicherheitslücken

🔧 Slack’s Workflow Builder gets several updates for making it easier to add automations


📈 22.63 Punkte
🔧 Programmierung

🔧 How to make Slack Workflow input form


📈 22.63 Punkte
🔧 Programmierung

📰 What are Slack Saved items and how can they improve your workflow?


📈 22.63 Punkte
📰 IT Nachrichten

📰 Slack bekommt Workflow Builder


📈 22.63 Punkte
🤖 Android Tipps

🕵️ CVE-2019-14367 | Slack-Chat up to 1.5.5 Slack Access Token information disclosure


📈 21.7 Punkte
🕵️ Sicherheitslücken

📰 Slack bekommt neue Funktion Slack Connect


📈 21.7 Punkte
🤖 Android Tipps

📰 Slack tips and tricks: How to use Slack to increase productivity


📈 21.7 Punkte
📰 IT Nachrichten

📰 Amazon schließt sich mit Slack zusammen: Mitarbeiter kommunizieren nun via Slack


📈 21.7 Punkte
📰 IT Nachrichten

matomo