This topic was automatically generated from Slack. You can find the original thread here.
can you show me an example of a new message to a slack channel, in node. I would like to return the message ID so I can reply in thread later on
This topic was automatically generated from Slack. You can find the original thread here.
can you show me an example of a new message to a slack channel, in node. I would like to return the message ID so I can reply in thread later on
To send a new message to a Slack channel, you can use the “Send Message to a Public Channel” action in Pipedream. Here’s how to use it: 1. Search for the Slack app from the step menu 2. Select the “Send Message to a Public Channel” action 3. Connect your Slack account 4. Select a Channel ID or pass a string from a previous step 5. Select a Text or pass a string from a previous step 6. At the bottom of the step, click Test to run the action and test the configuration The message ID (also known as the timestamp) will be available in the output of this action, which you can use later to reply in the thread.
can I do this with node only and props
Yes, you can send a message to a Slack channel using Node.js and props. Here’s an example of a Pipedream component that sends a message and returns the message ID: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { slack: { type: “app”, app: “slack”, }, channel: { type: “string”, label: “Channel ID”, }, text: { type: “string”, label: “Message Text”, }, }, async run({ $ }) { const response = await axios($, { method: “POST”, url: “https://slack.com/api/chat.postMessage”, headers: { Authorization: Bearer ${this.slack.$auth.oauth_access_token}
, “Content-Type”: “application/json”, }, data: { channel: this.channel, text: this.text, }, }); const messageId = response.ts; return { messageId }; }, });
: The default Slack actions return the message timestamp. That’s what you need to use later to reply in thread.
We do it all the time! (without any custom node step required)
hey , yeah I know, but I am trying to push that into a payload that is currently written in node to a datastore to retrieve later on
I would effectively need to run the custom node step, write to data-store, then post to slack, then update the datastore. just seems easier send the slack message via node in the same step, and then .push to the item before writing to the data-store (if that makes sense).