Skip to main content

Hi! 

I am trying to create a slack bot to send messages to a public channel with some customized color formatting (similar to this thread), so I used ‘API Request (Beta) in Slack’ action (this looks like a fairly new feature). While I was able to do the formatting as I need, it always sends the message as from me, instead of a slack bot. 

When you use the ‘Send Channel Message’ Slack action by Zapier, you can customize the bot name and icon. I am trying to do the same thing here, instead of spamming a channel with my name and profile picture 🙂 .

Reading the Slack API doc, I tried to add the `username` argument but no luck. Wondering does anyone have any insight here? Thank you!

Hi @ydong, welcome to the community!

Reading through the post you referenced and Sam’s article, it looks like the first thing you need to do is to create an app in Slack and use the authorization for that in the API action step, rather than your own. Is that something that you’ve tried? 

Looking at the Slack API, bots use different auth tokens to users so that’s where I would start: https://api.slack.com/methods/chat.postMessage

 

I hope that gets you pointed in the right direction, ​let us know if you have any questions!


Thank you @Danvers ! 

Yea I think that might be the issue. In the ‘API Request (Beta) in Slack’, it says ‘Authentication headers are included automatically’, so I assume it’s by default using my own user connection. So I might need to create an app and use the webhook instead.

I will try that out. 

 


Hi @ydong! 👋

Yep, that’s correct. The API Request (beta) action would use the authentication details for the connected Slack account when posting.

There was an as_user argument that used to be available for the chat.postMessage endpoint which would set whether a message should be posted as a user or bot. But it looks like that’s since been deprecated so you would need to set up the app in Slack and use a Webhooks by Zapier action instead. 

Please do let us know if you run into any issues on that, happy to help further! 🙂


Thank you @SamB ! Just want to say your tutorial has been super helpful :) 


Just to loop back here in case anyone wants to do the same thing -- creating a slack app and using the webhooks by Zapier worked for my use case.


YAY! That’s fantastic news, @ydong😁🎉 

I’m so pleased you found that tutorial helpful in getting everything set up. And thank you so much for hopping back in here to confirm it worked as hoped. It’s much appreciated. 

Happy Zapping! ⚡️