Question

Slack: Post to channel if exists, create that channel first, otherwise (or ignore errors)


Userlevel 1

Hi,

I’m trying to set up a Zap that posts to a channel with a custom name or create that channel first, if it doesn’t yet exist.

You can create a channel and post to that channel with no problem once. Next time, however, creating the channel will return the error message “name_taken”. So, I would either have to be able to check if the channel already exists before trying to create it or just ignore that error and continue posting to the already existing channel.

As Slack doesn’t offer a channel search, I can’t do the first and Zapier doesn’t seem to allow the latter.

Is that really just not possible?


8 replies

Userlevel 7
Badge +10

Hi @wef!

First, we have an existing feature request for that and I’ve added your vote for it :) 

To elaborate a bit on what Troy had proposed, this is how it could theoretically work:

Trigger: Whatever you’ve got now
Action: Slack — Create Channel

Paths

Path 1: continue if Channel Name exists (meaning you managed to create it in the previous step)
Action: Slack — Send Message to that channel

Path 2: continue if Channel Name does not exist (meaning you got that error and were not able to create the channel)
Action: Send someone a message, email, text, etc. advising them that the channel could not be created

NOTE: unless you have a record somewhere (like a Google Sheet) of Slack channel names and their IDs, you won’t be able to send a message to the channel that already existed, since in order to do so you’d need the ID:

So, it’s not perfect, and it would definitely be better to have a Find/Create Channel action (which is what that feature request is for). Hope that helps!

Userlevel 7
Badge +10

Hi @wef 

Consider using Paths in a Zap to handle the different use cases: https://zapier.com/apps/paths/integrations

Userlevel 1

Hi @wef 

Consider using Paths in a Zap to handle the different use cases: https://zapier.com/apps/paths/integrations

But how? I don’t see a way to check if a channel already exists and Slacks seem to be aborted right away when there’s an error.

Userlevel 3
Badge

@wef You’re right that there’s no way to search for a channel currently. Here’s a potential workaround:

Create a Zap using the Zapier Manager integration as a trigger. Have it look for Zap errors on the specific Zap you’re working on. It will trigger whenever you encounter the “name_taken” error. Then you can have this new zap post to the existing Slack channel. The trick will be getting the data from the first step into this new Zap. The feasibility of that all depends on where the data source is. 

 

Good luck!

XRay

Userlevel 1

@wef You’re right that there’s no way to search for a channel currently. Here’s a potential workaround:

Create a Zap using the Zapier Manager integration as a trigger. Have it look for Zap errors on the specific Zap you’re working on. It will trigger whenever you encounter the “name_taken” error. Then you can have this new zap post to the existing Slack channel. The trick will be getting the data from the first step into this new Zap. The feasibility of that all depends on where the data source is. 

 

Good luck!

XRay

Thank you, that sounds feasible. Isn’t provoking errors a problem, though? Doesn’t Zapier deactivate Zaps that cause too many errors?

Userlevel 3
Badge

@wef  Yes, that can be an issue, but usually when occurs when a Zap encounters multiple errors. Since this is just one step that is erroring it probably will not be shut off. If you want insurance you can create another Zap with the Zapier Manager that looks for that Zap being shut off and turns it back on.

 

Userlevel 1

On second thought, I even doubt that you can do that as you apparently can’t compose channel names based on a variable from the trigger. Seems like you need to create one Zap for each channel. That is quite disappointing.

Userlevel 7
Badge +10

@wef 

You could keep a lookup list in a GSheet or an Airtable to reference before

Basically, the first time a new Slack Channel is created, it then gets added to the Lookup List.

Plus, Slack relies on using the internal Slack ID for a Channel if being dynamically mapped.

So each time the Zap runs it first checks the Lookup List and proceeds down the desired path:

  1. Create & Send
  2. Map & Send

Give that a try and let us know how it goes.

Reply