Create workflow based on error thrown by n8n

Hi team,

I am having troubles setting up a workflow on a certain condition.
My workflow creates a specific name&date channel based on a /command, but when that naming is used, the workflow clashes. (i.e. channel-2023-08-23).
I am working towards incrementing the channel name, so that I could get:

  • channel-2023-08-23
  • if channel-2023-08-23 used → channel-2023-08-23-01
  • if channel-2023-08-23-01 used → channel-2023-08-23-02
    At this point, if I trigger two times the worfklow, the second time I get “ERROR: Slack error response: {“ok”:false,“error”:“name_taken”}”

How can I use it in my workflow so I can continue building up incrementation? :slight_smile:

Hey @GabCo,

What about getting a list of the channels in your workflow and sorting them alphabetically and looking that way?

Another option could be to set the Slack node to continue on fail and increase a counter by 1 and loop back on itself like the example below.

Hi @Jon!

Thanks a lot for the reply and sorry for late response.
I’ve tried the workflow you proposed, in theory it should work. However I throws me an error when the channel is already created, specifically ERROR: Slack error response: “name_taken” (the error is on step 2, Slack)
Which is weird as it should go further to step 3. I’ve checked in the JSON from Slack and there is no ‘name_taken’ field for successful runs, would it be the issue as this field might appear only on runs that are unsuccessful?

Hey @GabCo,

Do you have the Slack node set to continue on fail under the nodes settings?

hei @Jon,

I do now. And it works! :slight_smile:
The only issue left is that it goes on and on and does not stop, thus I get continuous channels being created. Any idea how I can stop it?

Hey @GabCo,

I would check the If node to see if anything needs to be adjusted based on the info coming out of the Slack node.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.