I currently have an automation that will send an email to Slack Channel #1 (TEST) if the issue's (custom field) TestFlag is set to ON and send an email to Slack Channel #2 (LIVE) if the issue's (custom field) TestFlag is set to OFF. This works fine and enables me to test my automation via my Slack TEST channel. However, it requires me to test the (custom field) TestFlag and create identical email messages that only differ by the "TO" field, which contains the appropriate Slack channel email address.
I'd like to be able to test (custom field) TestFlag and set a smart variable, or a field inside the issue with the email address of the appropriate Slack Channel, use a single email message, and send that email by specifying the "TO" field with the smart variable or the field inside the issue (whichever works, I don't need both).
Is there a way to do this in Jira Cloud?
Hi @Bill Glynn ,
To answer your immediate question, which seems to be "can I use a smart value in the To: field?", the answer is yes. You'll want to create an If/Else block to compare the values of your "TestFlag" field - and then as an action in the if/else, set a variable for the email addresses you want to use. Here's an example of the conditions and actions:
Hint: in the "Send email" action, you can start typing a pair of curly braces and Automation will suggest that the address you're putting in is a smart value:
Does your rule strictly need to send an email? Would it be possible to use the "Send Slack message" action instead, which uses webhooks? The formatting of messages coming in through webhooks is significantly cleaner than emails, as well as a little bit faster. An additional advantage is that by using webhooks, you can override the channel the message is going to instead of having to know its email address in advance.
The if/else block logic would still be the same if you used the "Send Slack message" rule instead.
Although theoretically you could have a custom field for the Slack channel name, and then just call that directly as your smart value in the rule.
If you've got a field called "Slack Channel" and have put in a value like #test or #live into the field, you can achieve the same results with one action and no if/else block.
Cheers,
Daniel
Voila, thanks Daniel, worked like a champ!!
I used your first method of a smart variable with the email address in it for now. I may get into the Web Hook method some other time, but for now I am very happy, thanks again!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Daniel Eads
I'm not sure if I was hallucinating or if I actually did get things to work once, but I can't get the variable method to work at all. I create the variable in Picture1, then try to send email using the variable (Picture2), but it doesn't work. I can successfully send email to that slack channel directly (Picture3), so I know the channel works. Going back to Picture1, I've tried this method of setting the variable as shown, I tried putting the address in single quotes, and in double quotes - nothing works.
Any thoughts on what I may be doing wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Daniel Eads
I think I figured out that there is a bug in how variables are handled. Trying to set the variable by using an If/Else block fails for both conditions, the error in the rule says it's trying to send to an empty address. However, setting the variable and then changing the variable within a simple If condition works for both the original setting and within the If condition when it changes the value. See diagram.
Any thoughts?
Thanks, Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, good catch! I believe you're right - I have some rules where the variable is instantiated before setting the variable again inside the block, so that appears to be a critical step I left out for you here. Great troubleshooting!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.