Jira automation: How to add an emoji to Slack message when issue conditions are met?
Asked by Jenni:

Hello,  

I have Jira Automation script that sends message to Slack when issues with certain conditions are created.  

However, I'd want to add a Slack emoji to the message whenever the issue is Blocker by priority.  

Currently my automation script has the following line:  
Priority: {{if(priority(Blocker))}}:blocker:{{/}} \*{{priority.name}}\*  

Which, hopefully would print ":blocker: Blocker" when it's a blocker, and otherwise just the name of the priority, such as "Normal". For clarification, :blocker: is the name of the emoji I'm trying to call on Slack.  

Is the condition correct? So far it doesn't seem to be working.


Answers:
author: Mykenna Cepek
body: Well, that wasn't as trivial as it looked to solve. :-\|

I'll start with the solution:

```
Priority: {{#if(equals(issue.priority.name,"1-Urgent"))}}:exclamation: {{/}}{{issue.priority.name}}
```

which produces in Slack, in our environment:

![Screen Shot 2022-02-03 at 8.12.57 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/181430i12C08D2C356564CC/image-size/large?v=v2&px=999 "Screen Shot 2022-02-03 at 8.12.57 AM.png")

HOWEVER, we have renamed our Status names to use a numeric prefix (so they will sort correctly by priority always). So in your case, of course, you'll want to use "Blocker" instead.

- - - - - - -

Here's why this ended up being non-trivial to solve:

* The documentation today ([here)](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#) for the the smart value conditional is, IMHO, wrong. Specifically, the required '#' is missing from many of their examples. I will submit feedback to Atlassian about that. It may be fixed by the time you read this.
* The OP use of "if(priority(Blocker))" was a red-herring, more wish than actual automation. The correct way to access the priority of an issue in automation is with {{issue.priority}}. Full documentation on how to access issue fields is [here](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/).
* One might have hoped that using "issue.priority" would have worked, as each priority has a numeric code. But "equals(issue.priority,3)" did not work, even if I quoted the 3. I plan to report this to Atlassian as a bug.

Note: I don't like having to rely on priority.name, as names can change (as I did once in our Jira instance, when adding the numeric prefixes). Relying on names could be considered brittle.

In our case, the internal priority numbers don't always match the prefixes used for priority names, as illustrated below. So I'd probably use priority.name in our rules for maximum clarity. Note how helpful it was to use the Audit Log action to confirm the actual values for the priority field:

![Screen Shot 2022-02-03 at 8.22.20 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/181432iC94A8D3F8D84DFAB/image-size/large?v=v2&px=999 "Screen Shot 2022-02-03 at 8.22.20 AM.png")

![Screen Shot 2022-02-03 at 8.22.14 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/181433iB04B034DE85479CC/image-size/large?v=v2&px=999 "Screen Shot 2022-02-03 at 8.22.14 AM.png")

comments: author: Jenni J?rvinen
body: Thank you for your message! My workaround for this was to do branched conditions with JQL checks for what the priority is, and then have customised Slack message for each priority with corresponding emojis. Yes, it was more work but in the end it was clearer than dealing with conditional logic.  

I'll keep this in mind though! The "Log action" was new to me, I need to try that.


author: Mykenna Cepek
body: Since your original question was "Is the condition correct?", and I believe I answered it, would you be willing to accept my answer? That's important feedback, especially for Community Leaders. Thanks!