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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Avinash Bhagawati _Appfire_ hello
how can i send the new assignee information? I have been triyng assignee.displayName but wont work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Very good!
Thanks for the help. I managed to make it work here for me.
For anyone who wants to use the model I used, just use the one below:
{% set payload = {
"channel": "#name-channel",
"text": "🚨 The card *{{issue.key}} - {{issue.summary}}* has just been created! \n\n- *Status*: {{issue.status.name}} \n- *Card Link*: <https://zenvia.atlassian.net/browse/{{issue.key}}> \n- *Issue Type*: {{issue.issueType.name}} \n- *Priority*: {{issue.priority.name}} \n\nPlease review and take action as soon as possible. :white_check_mark:"
} %}
{% set webhook_url = "https://hooks.slack.com/services/YOUR/WEBHOOK/HERE" %}
{{ webhook_url | callRest(verb="post", body=payload) }}It worked like a charm!! 🤩🤩
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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) }}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.