Skip to content

Commit

Permalink
fix(ms-teams)!: Use MS Power Automate for sending Teams messges
Browse files Browse the repository at this point in the history
Implements #1239
  • Loading branch information
Göran Sander committed Oct 1, 2024
1 parent 2769553 commit 4f46e60
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 97 deletions.
4 changes: 2 additions & 2 deletions src/config/production_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ Butler:
rateLimit: 300 # Min seconds between emails for a given taskID. Defaults to 5 minutes.
headScriptLogLines: 10
tailScriptLogLines: 10
templateFile: /path/to/teams/template/directory/failed-reload.handlebars
templateFile: /path/to/teams/template/directory/failed-reload-qseow.handlebars
reloadTaskAborted:
enable: false
webhookURL: <web hook URL from MS Teams>
Expand All @@ -271,7 +271,7 @@ Butler:
rateLimit: 300 # Min seconds between emails for a given taskID. Defaults to 5 minutes.
headScriptLogLines: 10
tailScriptLogLines: 10
templateFile: /path/to/teams/template/directory/aborted-reload.handlebars
templateFile: /path/to/teams/template/directory/aborted-reload-qseow.handlebars
serviceStopped:
webhookURL: <web hook URL from MS Teams>
messageType: formatted # formatted / basic. Formatted means that template file below will be used to create the message.
Expand Down
203 changes: 203 additions & 0 deletions src/config/teams_templates/failed-reload-qseow.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
{
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"contentUrl": null,
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.3",
"msteams": {
"width": "Full"
},
"body": [
{
"type": "TextBlock",
"size": "large",
"weight": "bolder",
"text": "Qlik Sense reload task failed",
"style": "heading",
"wrap": true
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "Image",
"style": "person",
"url": "https://raw.githubusercontent.com/ptarmiganlabs/butler/master/icon.png",
"altText": "Butler the Bot",
"size": "medium"
}
],
"width": "auto"
},
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"weight": "bolder",
"text": "Butler the Bot",
"wrap": true
},
{
"type": "TextBlock",
"spacing": "none",
"text": "",
"isSubtle": true,
"wrap": true
}
],
"width": "stretch"
}
]
},
{
"type": "FactSet",
"spacing": "large",
"facts": [
{
"title": "App name:",
"value": "{{appName}}"
},
{
"title": "App ID:",
"value": "{{appId}}"
},
{
"title": "Task name:",
"value": "{{taskName}}"
},
{
"title": "Task ID:",
"value": "{{tasId}}"
},
{
"title": "App owner:",
"value": "{{appOwnerName}}"
},
{
"title": "App owner user:",
"value": "{{appOwnerUserDirectory}}/{{appOwnerUserId}}"
},
{
"title": "App owner email:",
"value": "{{appOwnerEmail}}"
},
{
"title": "Reload started:",
"value": "{{executionStartTime.startTimeLocal1}}"
},
{
"title": "Duration:",
"value": "{{executionDuration.hours}} hours, {{executionDuration.minutes}} minutes, {{executionDuration.seconds}} seconds"
},
{
"title": "Reload ended:",
"value": "{{executionStopTime.stopTimeLocal1}}"
},
{
"title": "User starting the reload:",
"value": "{{executionStartTime.startTimeLocal1}}"
}
]
},

{
"type": "ActionSet",
"spacing": "extraLarge",
"separator": true,
"actions": [
{
"type": "Action.OpenUrl",
"title": "Open QMC",
"tooltip": "Open management console in Qlik Sense",
"url": "{{qlikSenseQMC}}",
"role": "button"
},
{
"type": "Action.OpenUrl",
"title": "Open hub",
"tooltip": "Open hub Qlik Sense",
"url": "{{qlikSenseQMC}}",
"role": "button"
}
]
},


{
"type": "Container",
"spacing": "extraLarge",
"style": "emphasis",
"items": [
{
"type": "TextBlock",
"size": "large",
"weight": "bolder",
"text": "Details",
"style": "heading"
},
{
"type": "FactSet",
"separator": true,
"facts": [
{
"title": "Execution result:",
"value": "{{executionStatusText}}"
},
{
"title": "Execution result code:",
"value": "{{executionStatusNum}}"
},
{
"title": "Log timestamp:",
"value": "{{logTimeStamp}}"
},
{
"title": "Log message:",
"value": "{{logMessage}}"
}
]
},
{
"type": "CodeBlock",
"codeSnippet": "{{executionDetailsConcatenated}}"
}
]
},
{
"type": "Container",
"spacing": "extraLarge",
"style": "emphasis",
"items": [
{
"type": "TextBlock",
"size": "large",
"weight": "bolder",
"text": "End of script log",
"style": "heading"
},
{
"type": "TextBlock",
"size": "small",
"weight": "normal",
"text": "Last {{scriptLogTailCount}} rows shown. The script log contains {{scriptLogSize}} rows in total.",
"style": "heading"
},
{
"type": "CodeBlock",
"codeSnippet": "{{scriptLogTail}}"
}
]
}
]
}
}
]
}
89 changes: 0 additions & 89 deletions src/config/teams_templates/failed-reload.handlebars

This file was deleted.

12 changes: 6 additions & 6 deletions src/lib/msteams_notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,16 +483,16 @@ export function sendReloadTaskFailureNotificationTeams(reloadParams) {
executionDetails: scriptLogData.executionDetails,
executionDetailsConcatenated: scriptLogData.executionDetailsConcatenated
.replace(/([\r])/gm, '')
.replace(/([\n])/gm, '\\n\\n')
.replace(/([\n])/gm, '\\n')
.replace(/([\t])/gm, '\\t'),
scriptLogSize: scriptLogData.scriptLogSize,
scriptLogHead: scriptLogData.scriptLogHead
.replace(/([\r])/gm, '')
.replace(/([\n])/gm, '\\n\\n')
.replace(/([\n])/gm, '\\n')
.replace(/([\t])/gm, '\\t'),
scriptLogTail: scriptLogData.scriptLogTail
.replace(/([\r])/gm, '')
.replace(/([\n])/gm, '\\n\\n')
.replace(/([\n])/gm, '\\n')
.replace(/([\t])/gm, '\\t'),
scriptLogTailCount: scriptLogData.scriptLogTailCount,
scriptLogHeadCount: scriptLogData.scriptLogHeadCount,
Expand Down Expand Up @@ -629,16 +629,16 @@ export function sendReloadTaskAbortedNotificationTeams(reloadParams) {
executionDetails: scriptLogData.executionDetails,
executionDetailsConcatenated: scriptLogData.executionDetailsConcatenated
.replace(/([\r])/gm, '')
.replace(/([\n])/gm, '\\n\\n')
.replace(/([\n])/gm, '\\n')
.replace(/([\t])/gm, '\\t'),
scriptLogSize: scriptLogData.scriptLogSize,
scriptLogHead: scriptLogData.scriptLogHead
.replace(/([\r])/gm, '')
.replace(/([\n])/gm, '\\n\\n')
.replace(/([\n])/gm, '\\n')
.replace(/([\t])/gm, '\\t'),
scriptLogTail: scriptLogData.scriptLogTail
.replace(/([\r])/gm, '')
.replace(/([\n])/gm, '\\n\\n')
.replace(/([\n])/gm, '\\n')
.replace(/([\t])/gm, '\\t'),
scriptLogTailCount: scriptLogData.scriptLogTailCount,
scriptLogHeadCount: scriptLogData.scriptLogHeadCount,
Expand Down

0 comments on commit 4f46e60

Please sign in to comment.