Skip to content

Instantly share code, notes, and snippets.

@mozziemozz
Created September 3, 2022 12:44
Show Gist options
  • Select an option

  • Save mozziemozz/315f3d455144ea86bc2c94c0a8a92a45 to your computer and use it in GitHub Desktop.

Select an option

Save mozziemozz/315f3d455144ea86bc2c94c0a8a92a45 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 = "Your Runbook Webhook URL"
$refreshUri = "Your Refresh Card Function URL"
$actionCardCq = @'
{
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"summary": "Card \"Test card\"",
"themeColor": "0078D7",
"title": "Edit Call Queue",
"text": "Choose a Call Queue from the list and enter the forwarding target number.",
"potentialAction": [
{
"@type": "ActionCard",
"name": "Update Call Queue",
"inputs": [
{
"@type": "MultichoiceInput",
"id": "list",
"title" : "Select a Call Queue",
"choices": [
Your List of choices goes here.
]
},
{
"@type": "MultichoiceInput",
"id": "actionType",
"title": "Choose an action for the selected Call Queue.",
"isMultiSelect": "false",
"style": "expanded",
"choices": [
{ "display": "Enable Immediate Forwarding to External Number", "value": "overflowEnableImmediate" },
{ "display": "Disable Immediate Forwarding to External Number", "value": "overflowDisableImmediate" },
{ "display": "Update Forwarding to External Number on Timeout", "value": "timeOutUpdateNumber" }
]
},
{
"@type": "TextInput",
"id": "number",
"isMultiline": false,
"isRequired": true,
"title": "Enter the target number in E.164 format e.g. +41440000000."
}
],
"actions": [
{
"@type": "HttpPOST",
"name": "Submit Config",
"target": "refreshUriPlaceholder",
"body": "{\r\n \"Number\": \"{{number.value}}\", \"QueueId\": \"{{list.value}}\", \"actionType\": \"{{actionType.value}}\" \r\n}",
"headers": [
{
"Content-Type": "application/json"
}
]
}
]
}
]
}
'@
$actionCardCq = $actionCardCq.Replace("refreshUriPlaceholder",$refreshUri)
Invoke-RestMethod -uri $uri -Method Post -body $actionCardCq -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