Hello,
I want to send a slack message with webhook from JMWE app like it is in Jira native automation on a certain trigger.
How is it possible to post the webhook.
Hi @Tarieli Gvritishvili Good day!
In this case, you can use a Build-your-own (JMWE app) post-function, and use the callRest filter: https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/465242995/callRest
Please find below example.
{% set payload = {"channel": "#test-001","username": "webhookbot","text": "This is posted for #test-001 and comes from a bot named webhookbot.","icon_emoji": ":ghost:"} %}{% set webhook_url = "https://hooks.slack.com/services/T013H6GS22J/XXXXXX/XXXXXXXXXXoBJutA185uAWF" %}{{ webhook_url | callRest(verb="post", body=payload) | dump(2) }}
I hope this helps!
BTW, I'm from Appfire, the vendor of JMWE app.
Thanks,Avinash
Works great, thanks a lot.
Is it possible to call issue fields into the body of the text? This is working well except that it is showing "... for {{issue.fields.customfield_10100}} was transitioned..." in the body of the slack message instead of the value of that field.
It is, but not using {{}} since you're building a string, not the output. So you would do:
"text":"for "+issue.fields.customfield_10100+" was transitioned"
Wanted to contribute because this article helped a lot. Our org uses a lot of Slack reports that go out to the teams. Important to note that I'm using Scheduled Actions and setting my target issue to a singular issue because JMWE will send per each issue within the JQL.
So here are two different cases that we were able to whip up. I hope this helps anyone being forced to switch to cloud.
{% set issues = "filter in 'test filter'" | searchIssues(maxResults=5, fields="summary,updated") %}{# #channel name #}{% set webhook_url = "https://hooks.slack.com/services/YOUR/WEBHOOK/HERE" %}{% set baseUrl = "baseUrl" | serverInfo %}{% if issues | length > 0 %}{% set message = "" %}{% for issue in issues %}{% set message = message + "<" + baseUrl + "/browse/" + issue.key + "|" + issue.fields.summary + ">\n" %}{% endfor %}{% set payload = { "blocks": [ { "type": "header", "text": { "type": "plain_text", "text": "Daily Report" } }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": message } } ]} %}{{ webhook_url | callRest(verb="post", body=payload) | dump(2) }}{% endif %}
{% set issues = "filter in 'test filter'" | searchIssues(maxResults=5, fields="summary,updated") %}{# #channel name #}{% set webhook_url = "https://hooks.slack.com/services/YOUR/WEBHOOK/HERE" %}{% set baseUrl = "baseUrl" | serverInfo %}{% if issues | length > 0 %}{% set message = "" %}{% for issue in issues %}{% set message = message + "<" + baseUrl + "/browse/" + issue.key + "|" + issue.key + "> — " + issue.fields.summary + " — " + (issue.fields.updated | date("DD/MMM/YY HH:mm")) + "\n" %}{% endfor %}{% set payload = { "blocks": [ { "type": "header", "text": { "type": "plain_text", "text": "Daily Report" } }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": message } } ]} %}{% else %}{% set payload = { "blocks": [ { "type": "header", "text": { "type": "plain_text", "text": "Daily Report" } }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": "No issues found :white_check_mark:" } } ]} %}{% endif %}{{ webhook_url | callRest(verb="post", body=payload) | dump(2) }}
It looks like you're new here. Sign in or register to get started.