How to Create a Workflow Triggered by Specific Emoji Reactions and Search for Thread Responses in Slack?

This topic was automatically generated from Slack. You can find the original thread here.

I am creating a workflow and the trigger is when someone reacted using a specific emoji on s Slack message, I want the next action to look for the thread responses. How can I do that?

To create a workflow in Pipedream that triggers when someone reacts with a specific emoji on a Slack message and then looks for the thread responses, you can follow these steps: 1. Trigger Setup: - Use the New Reaction Added (Instant) trigger from the Slack app. This trigger will activate your workflow whenever a new reaction is added to a message in Slack. - You can find this trigger by searching for the Slack app in the trigger menu and selecting the New Reaction Added (Instant) trigger. Connect your Slack account and follow the configuration instructions. 2. Action to Retrieve Thread Responses: - After setting up the trigger, you need to add an action to retrieve the thread responses. You can use the Slack API to fetch the thread messages. - Here’s an example of how you can set up a Pipedream component to fetch thread messages: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { slack: { type: "app", app: "slack", }, channel: { type: "string", label: "Channel ID", description: "The ID of the channel where the message is located.", }, thread_ts: { type: "string", label: "Thread Timestamp", description: "The timestamp of the parent message of the thread.", }, }, async run({ steps, $ }) { const response = await axios($, { url: `https://slack.com/api/conversations.replies`, headers: { Authorization: `Bearer ${this.slack.$auth.oauth_access_token}`, }, params: { channel: this.channel, ts: this.thread_ts, }, }); return response.messages; }, }); - Props Explanation: - channel: The ID of the Slack channel where the message is located. You can pass this from a previous step or set it manually. - thread_ts: The timestamp of the parent message of the thread. This is usually the timestamp of the message that received the emoji reaction. 3. Testing: - After setting up the trigger and action, test your workflow to ensure it behaves as expected. You can do this by adding a reaction to a message in Slack and observing if the workflow retrieves the thread responses correctly. By following these steps, you can create a Pipedream workflow that triggers on a specific emoji reaction and retrieves the thread responses from Slack. If you need further assistance, feel free to ask!

I need a js code that will extract the Notion page ID from the Notion page URL

To extract the Notion page ID from a Notion page URL using JavaScript, you can use the following code snippet. This code assumes that the URL follows the standard Notion URL format, where the page ID is typically the last part of the URL, after the last hyphen (-): ```
function extractNotionPageID(url) { // Split the URL by hyphens const parts = url.split(‘-’); // The page ID is typically the last part of the URL const pageID = parts[parts.length - 1]; // Remove any trailing characters after the page ID (like query strings) return pageID.split(‘?’)[0]; } // Example usage const notionURL = “Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.”; const pageID = extractNotionPageID(notionURL); console.log(“Notion Page ID:”, pageID);

in the workflow I’s creating a Notion page URL is identified to one of the step. From there I need to extract the Notion Page ID.

To extract the Notion Page ID from a Notion page URL in a Pipedream workflow, you can use a code step to parse the URL and retrieve the Page ID. Here’s a step-by-step guide on how to do this: 1. Add a Code Step: In your Pipedream workflow, add a new code step where you will write the logic to extract the Page ID. 2. Write the Code: Use the following JavaScript code to extract the Page ID from the URL. This code assumes that the URL is passed to the step as an input or is available from a previous step. export default defineComponent({ async run({ steps }) { // Replace 'steps.previous_step_name.page_url' with the actual path to your URL const pageUrl = steps.previous_step_name.page_url; // Extract the Page ID from the URL const pageIdMatch = pageUrl.match(/([a-f0-9]{32})/); if (pageIdMatch) { const pageId = pageIdMatch[0]; return pageId; } else { throw new Error("Page ID not found in the URL"); } } }); 3. Test the Code: Run the step to ensure it correctly extracts the Page ID from the URL. ### Explanation: - The code uses a regular expression to match a 32-character hexadecimal string, which is the format of a Notion Page ID. - It assumes that the URL is available in a previous step’s output. Replace 'steps.previous_step_name.page_url' with the actual path to your URL in the workflow. - If the Page ID is found, it is returned; otherwise, an error is thrown. This approach will help you extract the Notion Page ID from a URL within your Pipedream workflow. If you have any issues or need further assistance, feel free to ask!