How to Write a Node.js Code Step to Send a Custom Slack Message Using the Slack Bot App from Pipedream?

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

Hey , please write a nodejs code step to send a custom Slack message using the Slack Bot app from Pipedream.

Sure, here’s a Pipedream component that sends a custom message using the Slack Bot app: import { axios } from "@pipedream/platform" export default defineComponent({ props: { slack: { type: "app", app: "slack", }, channel: { type: "string", label: "Channel", description: "The channel to send the message to", }, message: { type: "string", label: "Message", description: "The message to send", }, }, async run({ $ }) { const response = await axios($, { method: "POST", url: ``, headers: { Authorization: `Bearer ${this.slack.$auth.bot_token}`, "Content-Type": "application/json", }, data: { channel:, text: this.message, }, }); return response; }, }); In this code, you need to replace channel and message with the actual channel ID and the message you want to send. This code uses the Slack Bot token to authenticate and send a message to the specified channel. Please note that you need to connect your Slack account in the Pipedream UI when you add this code step to your workflow.

Thank you ! :pray:

You’re welcome! If you have any other questions or need further help, feel free to ask. Happy coding!

Nice hallucination on the import there :joy:

Unfortunately this is Slack’s fault. If a user signs up with a name / email with the word “pipedream”, it will match it on the @pipedream import. I’ve found no way to reliably stop Slack from doing that. No API flag exists to stop it as far as I’ve been able to find

If you know of a way lmk and I’m happy to try it

Also have you used the AI code gen in the UI? That’s generally going to produce more reliable code and it would nail the app name slug as slack_bot too

Yup! I tried both, and ended up going with the UI for that small difference. :+1:

And also no need to bug everyone here. :sweat_smile:

Setting the link_names parameter to false had no effect on fixing the @pipedream import?


you would think

but no

I think maybe because that param “No longer supports linking individual users”

so I think their mechanism for tagging users vs. groups must be different

And it’s in a code block too… even dumber to link it :man-facepalming:

haha I know