Open kengibous opened 4 months ago
Instead of using the AdaptiveCard format I left it as MessageCard and was able to get the Teams notification to come through using Workflows with the new webhook URL. The trick in the workflow was to...
<p style="border-top:@{triggerBody()?['themeColor']} solid;border-bottom:grey thin solid;border-left:grey thin solid;border-right:grey thin solid;padding-left:4px;padding-right:4px;">@{triggerBody()?['text']}</p>
@{triggerBody()?['title']}
The problem I see with this approach, and one that I'm not sure AdaptiveCard would solve, is that it doesn't handle markdown properly. In the message body example above using [runbook details](...)
it will not turn into a hyperlink... I was thinking about handling this by passing in a URL parameter in the json and then have the Workflow convert it to a hyperlink using html. Example <a href="@{triggerBody()?['url']}">runbook details</a>
@delphe valid point, I suppose using the AdaptiveCard format is not absolutely necessary depending on how you configure a PowerAutomate workflow
@delphe actually i believe the AdaptiveCard format will handle markdown - https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cdesktop%2Cconnector-html#format-cards-with-markdown
I was able to just update the webhook url to migrate to the logic app url.
Then, using Post As User, using this json:
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.4",
"type": "AdaptiveCard",
"fallbackText": "@{triggerBody()?['title']}",
"body": [
{
"type": "TextBlock",
"text": "@{triggerBody()?['text']}",
"wrap": true
}
]
}
And @{triggerBody()?['title']}
as the subject, as suggested before.
Thanks @tbolon ! I went back to using "Post card in a chat or channel" and tried that JSON, which resolved my issue with using markdown. I played around with using @{triggerBody()?['themeColor']}
and came up with the following...
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.4",
"type": "AdaptiveCard",
"fallbackText": "@{triggerBody()?['title']}",
"body": [
{
"type": "TextBlock",
"text": "@{triggerBody()?['text']}",
"wrap": true,
"color": "@{triggerBody()?['themeColor']}"
}
]
}
Although, the only acceptable "colors" found in adaptive-cards schema are: "default", "dark", "light", "accent", "good", "warning", "attention"
glad I found this today, thank you all for contributing. I don't like that it posts as "firstname lastname via workflows". I see there's a way to add a bot via copilot, but I don't appear to have a license to use copilot software. Any suggestions?
I will certainly migrate out of using adaptive cards, as it seems they are extremely limited in number of chars, and my release messages are quite long.
Because they only accept HTML, I have alread switched my changelog generator to output HTML instead of markdown. Now I will try to use the post message action.
Step template
Microsoft Teams - Post a message - 110a8b1e-4da4-498a-9209-ef8929c31168
Step version
24
Octopus version
2024.2.9274
Step template parameter inputs
What happened
The message does indeed post to the teams channel when use the soon to be deprecated Office 365 connectors - https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/. The successor which is to use Microsoft Teams workflows (Power Automate) - it appears that the messages should be in the AdaptiveCard format - https://learn.microsoft.com/en-us/connectors/teams/?tabs=text1#microsoft-teams-webhook.
Reproduction steps
Complete the necessary parameters and the webhook will use the MessageCard (legacy) format.
More Information
I believe some changes to the Powershell script can be made to adopt the AdaptiveCard format. I am happy to submit a PR as well.