Skip to content

Instantly share code, notes, and snippets.

@mozziemozz
Last active May 17, 2022 19:04
Show Gist options
  • Save mozziemozz/0c3b259ab033bd39880a3665f48cd760 to your computer and use it in GitHub Desktop.
Save mozziemozz/0c3b259ab033bd39880a3665f48cd760 to your computer and use it in GitHub Desktop.
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
$uri = ""
$refreshUri = ""
$actionCardAa = @'
{
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"summary": "Card \"Test card\"",
"themeColor": "00A4EF",
"title": "Manually Open or Close Auto Attendant",
"text": "Click 'Open' or 'Close' to manually override your scheduled office hours.",
"potentialAction": [
{
"@type": "ActionCard",
"name": "Add a comment",
"inputs": [
{
"@type": "MultichoiceInput",
"id": "list",
"isMultiSelect": "false",
"choices": [
{ "display": "Open", "value": "open" },
{ "display": "Close", "value": "close" }
]
}
],
"actions": [
{
"@type": "HttpPOST",
"name": "Submit Config",
"target": "refreshUriPlaceholder",
"body": "{\r\n \"action\": \"{{list.value}}\", \"changeType\": \"autoAttendant\"\r\n}",
"headers": [
{
"Content-Type": "application/json"
}
]
}
]
}
]
}
'@
$actionCardAa = $actionCardAa.Replace("refreshUriPlaceholder",$refreshUri)
Invoke-RestMethod -uri $uri -Method Post -body $actionCardAa -ContentType 'application/json; charset=UTF-8'
$body = @'
{
"@context": "https://schema.org/extensions",
"@type": "MessageCard",
"themeColor": "00A4EF",
"title": "Config Change Request received",
"text": "Your config change request has been received."
}
'@
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
headers = @{'content-type'='application/json'; 'charset'='utf8'; 'CARD-UPDATE-IN-BODY'='true'}
StatusCode = [HttpStatusCode]::OK
Body = $body
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment