Jira Automation sent duplicated messages to Slack
Asked by Davyd Derkach:

Hello, everybody!  

**I have created following automation that sends message containing Jira Issue keys and Issue summary to Slack:**   

![image_2024-07-23_192854414.png](https://community.atlassian.com/t5/image/serverpage/image-id/337399i01A413ED44A44CB7/image-size/large?v=v2&px=999 "image_2024-07-23_192854414.png")  

1. As a trigger I have incoming webhook with a list of Jira Issue Keys.  
2. Then I create a variable from {{webhookData.issues}}

3. After that there is lookup over {{webhookData.issues}}

4. Then sending following message to slack:  

*Time: {{webhookData.timestamp}}*

*Issues included in this release:*

*{{#lookupIssues}}*

*\* {{key}} {{summary}}*

*{{/}}
5.* After that some transition of the issues.  

**Here example of what my API call looks like:**   

*curl -X POST -H 'Content-type: application/json' --data '{"issues":\["BDO-391","BDO-392"\], "data": {"issues":\["BDO-391","BDO-392"\], "timestamp":"13:30"}}' <https://automation.atlassian.com/pro/hooks/>\<my-webhook\>*   

**Here a duplicated messages in Slack for each Jira Issue:**   

![test-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/337400i401D1CFE25212D2D/image-size/large?v=v2&px=999 "test-1.png")  

Thanks in advance for your help!


Answers:
author: Bill Sheboy
body: Hi [@Davyd Derkach](/t5/user/viewprofilepage/user-id/5550816) -- Welcome to the Atlassian Community!

The rule's trigger is using the option "Issues provided in the webhook HTTP POST body", and so the steps loop over each issue provided.

You could change your rule to instead use the option "No issues from the webhook" and pass only the issue keys in the custom data. Then you could control how the rule handles them.

For example, the data from the sending application could be passed as:

```
{ "data": { "keys": "BDO-392,BDO-391" } }
```

And then the JQL to access the issues in your rule would be:

```
 key IN ( {{webhookData.keys}} ) 
```

Kind regards,  
Bill

comments: author: Davyd Derkach
body: Hello, Bill!  
Thanks a lot for quick response.  

Your suggestion of using ***key IN ( {{webhookData.keys}} )*** helped to not receive couple messages in Slack. For now I receive only one as expected.  

**However the branch part, in which I check for issue status and then perform a transition is not working with this setup:**   

![test-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/337438iF66A6F484F0720B0/image-size/large?v=v2&px=999 "test-1.png")  

<br />

In Rule "Issue fields condition" the warning appeared with following details:  

![test-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/337439i5A76D63868BE6A22/image-size/large?v=v2&px=999 "test-2.png")  

In "Advanced branching" i use smart value {{webhookData.keys}} in for each (visible on first screenshot).  

**The API call that I sent:**   

*curl -X POST -H 'Content-type: application/json' --data '{"data": {"keys": "BDO-392,BDO-391"}}' <https://automation.atlassian.com/pro/hooks/>\<my-webhook\>* ----  
Thanks in advance and sorry for my sometimes lazy questions since it\`s my first task related to Jira automation(  

<br />


author: Bill Sheboy
body: You could replace the advanced branch with a branch on JQL with the same JQL I provided for the Lookup Issues action. That will enable iterating over the issues.


author: Davyd Derkach
body: Thank again [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)  
It\`s helped me to receive only one message in Slack and to transition issues correctly.  

**Here is final look of my automation for others, who may face same issues:**   

![image_2024-07-23_234445965.png](https://community.atlassian.com/t5/image/serverpage/image-id/337455iDC1C50C49B7672E6/image-size/large?v=v2&px=999 "image_2024-07-23_234445965.png")  

**The API call that I execute, looks like this:**   

*curl -X POST -H 'Content-type: application/json' --data '{"data": {"keys": "BDO-392,BDO-391"}}' <https://automation.atlassian.com/pro/hooks/>\<your-webhook\>*   


author: Davyd Derkach
body: Hello again, [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)  
I have one more question and maybe you can help me with it?  

Currently after each pipeline run I a script which use a webhook API call to sent Jira Issue keys that related to current release to my Jira Automation:  

*curl -X POST -H 'Content-type: application/json' --data '{"data": {"keys": "BDO-392,BDO-391"}}' <https://automation.atlassian.com/pro/hooks/>\<your-webhook\>*   

Also, I need to sent another information like release tag version, release date etc. and later this will be sent to Slack with my Jira Automation above.  

**So I am wondering is there a way not to use script with API call to sent Jira Issue keys and another information? I saw in documentation something about smart values like: <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-development/>**   

But I cant find information whether these smart values will be available in case I am not send them via Webhook URL but just reference them into automation. I have GitLab integration with my Jira.  

Also maybe you know smart values that can help me to retrieve Jira issue keys that related to current release tag, Release Engineer name, date of pipeline run and Jira issue summary?  

Thanks in advance!  


author: Bill Sheboy
body: In general, most of the automation smart values apply when an issue is available to the rule.

For an incoming webhook from Jira itself, it is possible to send the issue content. But your source for the webhook is different.

Using some of the data you reference, you would likely need to use your source control / release management tool to find the relevant issues' keys and then look them up with JQL once inside the automation rule.


Tags: duplicate

lookup

slack

webhook