Open ricalenil opened 6 years ago
I'm encountering the same issue. It works using curl. I'm thinking it should be working in Tower as well.
@ricalenil Had the same issue trying to post notifications to Rocket Chat using Webhook notification template type, as this posts a message like '{"body": "message"}', while Rocket Chat (and Mattermost, MS Teams) use Slack webhooks: '{"text": "message"}'.
I got around this by using Mattermost as the notification template type, should work for MS Teams too.
@falencastro I am trying to use {"text": "message"} as http header but still getting the same error
Same here. I'm not a fan of Teams, but I imagine this is broken as an advertised feature in Tower.
@Infectsoldier It's not a http header, it's the payload, which you can't alter. A WebHook Notification template type won't work for Mattermost/MS Teams/RocketChat or any other Slack compatible communication platform.
Try selecting Mattermost as the notification type and point it to your Teams webhook url; This should do the trick.
@falencastro I am using ansible tower not awx and looks like it does not have Mattermost as the notification type.
AWX is the upstream of Tower, so it may and will have a newer feature set at any particular point in time.
So then it is best to report this issue with Tower directly to RedHat?
Sent from mobile
On Mar 7, 2018 8:04 AM, "Bill Nottingham" notifications@github.com wrote:
AWX is the upstream of Tower, so it may and will have a newer feature set at any particular point in time.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ansible/awx/issues/885#issuecomment-371187712, or mute the thread https://github.com/notifications/unsubscribe-auth/Ad1pYdynHDi_Uv2A9TIKLiZA9IfEF4Ygks5tcAUQgaJpZM4RL_Oo .
As always, if you are having issues with Tower, contact your Red Hat support rep.
This is working with mattermost option, but it would be more clean to add a teams option. Someone of Awx here?
Sent with GitHawk
Any traction on this? Seems like most of the code is already in place for this since the Mattermost notification type is seemingly working. Are PR's welcome and if so is there anything I need to do before cloning the project and starting work on this?
PRs are definitely welcome.
@falencastro - Worked like a charm on AWX. Thank you
Hi All !
{ "Text":"Test Connection" }
{ "content-type":"application/json" }
hope helpful
Also here are some useful custom message examples that would be great have in the documentation
HTTP HEADERS
{
"content-type": "application/json"
}
Start Message Body
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"summary": "Job started: {{ job.name }}",
"title": "Job started: {{ job.name }}",
"themeColor": "FFFFFF",
"sections": [
{
"title": "Details",
"facts": [
{
"name": "Start date",
"value": "{{ job.started }}"
},
{
"name": "Inventory",
"value": "{{ job.summary_fields.inventory.name }}"
},
{
"name": "Created by",
"value": "{{ job.summary_fields.created_by.first_name }} {{ job.summary_fields.created_by.last_name }}"
}
]
}
],
"potentialAction": [
{
"@context": "http://schema.org",
"@type": "ViewAction",
"name": "View on Ansible",
"target": [
"{{ url }}"
]
}
]
}
Success Message Body
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"summary": "Job success: {{ job.name }}",
"title": "Job success: {{ job.name }}",
"themeColor": "008000",
"sections": [
{
"title": "Details",
"facts": [
{
"name": "Start date",
"value": "{{ job.started }}"
},
{
"name": "End date",
"value": "{{ job.finished }}"
},
{
"name": "Inventory",
"value": "{{ job.summary_fields.inventory.name }}"
},
{
"name": "Created by",
"value": "{{ job.summary_fields.created_by.first_name }} {{ job.summary_fields.created_by.last_name }}"
}
]
}
],
"potentialAction": [
{
"@context": "http://schema.org",
"@type": "ViewAction",
"name": "View on Ansible",
"target": [
"{{ url }}"
]
}
]
}
Error Message Body
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"summary": "Job error: {{ job.name }}",
"title": "Job error: {{ job.name }}",
"themeColor": "FF0000",
"sections": [
{
"title": "Details",
"facts": [
{
"name": "Start date",
"value": "{{ job.started }}"
},
{
"name": "End date",
"value": "{{ job.finished }}"
},
{
"name": "Inventory",
"value": "{{ job.summary_fields.inventory.name }}"
},
{
"name": "Created by",
"value": "{{ job.summary_fields.created_by.first_name }} {{ job.summary_fields.created_by.last_name }}"
}
]
}
],
"potentialAction": [
{
"@context": "http://schema.org",
"@type": "ViewAction",
"name": "View on Ansible",
"target": [
"{{ url }}"
]
}
]
}
Also here are some useful custom message examples that would be great have in the documentation
Stealing this!
@daniego Is that layout something you've successfully used in AWX? If so, how?
@outcast Cheers!
@stuartluscombe that's fully working and I'm using it in production.
Just create a webhook notification, set TARGER URL
with the one you get from Teams while creating the webhook, toggle CUSTOMIZE MESSAGES...
on and paste the code above.
As far as I can remember I don't think that the test message works, but the actual notification does!
In my case it only worked after changing from "Webhook" to "Mattermost"
Hey @daniego the start,sucess,failure notications are working for me like you mentione above but when it comes to approval messages I am not able to get the notification to teams. Can I get any reason. I am using webhook type of notification. {"body": "The approval node \"{{ approval_node_name }}\" was approved. {{ workflow_url }}"} I am using same sample message body which was default for awx while creating awx webhook notification type. Can I get some help here. Thanks in advance.
Hi @venu1428 try something like this
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"summary": "The approval node "{{ approval_node_name }}" was approved. {{ workflow_url }}",
"title": "The approval node "{{ approval_node_name }}" was approved. {{ workflow_url }}",
"themeColor": "008000"
}
Hi @venu1428 try something like this
{ "@type": "MessageCard", "@context": "http://schema.org/extensions", "summary": "The approval node "{{ approval_node_name }}" was approved. {{ workflow_url }}", "title": "The approval node "{{ approval_node_name }}" was approved. {{ workflow_url }}", "themeColor": "008000" }
Hey @daniego thank you for the responce I have tried this one it is working fine upto this.But I am unable to get the notification of action or potential action case. like when I put { "@type": "MessageCard", "@context": "https://schema.org/extensions", "summary": "Workflow approval node got Approved: {{ approval_node_name }}", "title": "Workflow approval node got Approved: {{ approval_node_name }}", "themeColor": "008000", }
this is working fine but when I will put
{ "@type": "MessageCard", "@context": "https://schema.org/extensions", "summary": "Workflow approval node got Approved: {{ approval_node_name }}", "title": "Workflow approval node got Approved: {{ approval_node_name }}", "themeColor": "008000", "potentialAction": [ { "@context": "http://schema.org", "@type": "ViewAction", "name": "View on Ansible", "target": [ "{{ workflow_url }}" ] } ] } It is not working. any suggestions.
I'm running into issues with this too ("Error sending notification webhook: 400"). If I use the same content, headers and URL with curl, I can send a message just fine. I also can't see anywhere in the logs where I can see any error body that might be coming back from Teams.
Thanks @daniego for the POST bodies for Teams. They are working great for us on manually triggered jobs, but we don't get any notification for scheduled jobs.
I dug into the problem and discovered that the webhook notifier sends an empty body (which causes Teams to ignore the notification all together) if any of the template fields trigger an UndefinedError.
On scheduled jobs "job.summary_fields.created_by" is undefined, so we removed the whole "Created by" section as a quick fix.
I'm running into issues with this too ("Error sending notification webhook: 400"). If I use the same content, headers and URL with curl, I can send a message just fine. I also can't see anywhere in the logs where I can see any error body that might be coming back from Teams.
@howardjones Did you find a way to fix this?
Nevermind. Only the "test"-Button is broken.
Also here are some useful custom message examples that would be great have in the documentation
HTTP HEADERS
{ "content-type": "application/json" }
...
This worked for me. Maybe this should be added to the documentation. The only improvement is that "job.summary_fields.created_by" is undefined on startup. So the "Created by" section can be removed for the "Start Message Body".
ISSUE TYPE
COMPONENT NAME
SUMMARY
I'm trying to setup webhooks notifications with Microsoft Teams, but i'm getting errors. Maybe a misconfiguration, but there is no documentation about how to do it.
Maybe someone already achieved this by webhooks, but it would be great to add an option to do it like slack.
ENVIRONMENT
STEPS TO REPRODUCE
as described here: https://docs.ansible.com/ansible-tower/latest/html/userguide/notifications.html#webhook
and here: https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/connectors
EXPECTED RESULTS
Select notification type Microsoft Teams, and configure the options. Or a documentation of how to do it with webhook option.
ACTUAL RESULTS
With webhook I'm receiving this error. ERROR awx.main.notifications.webhook_backend Error sending notification webhook: Summary or Text is required.
ADDITIONAL INFORMATION