Created
September 3, 2022 12:55
-
-
Save mozziemozz/7928bf7f6dabcbf0c5283566511488e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using namespace System.Net | |
| # Input bindings are passed in via param block. | |
| param($Request, $TriggerMetadata) | |
| $action = $Request.Body.actionType | |
| $callQueueName = $Request.Body.QueueName | |
| $callQueueId = $Request.Body.QueueId | |
| $targetNumber = $Request.Body.Number | |
| $uri = "Your Runbook Webhook URL" | |
| $body = @' | |
| { | |
| "@context": "https://schema.org/extensions", | |
| "@type": "MessageCard", | |
| "themeColor": "00A4EF", | |
| "title": "Config Change Request Received", | |
| "text": "Your change has been submitted to the Azure Runbook. actionPlaceholder" | |
| } | |
| '@ | |
| switch ($action) { | |
| overflowEnableImmediate { | |
| $actionFriendly = "The Call Queue will forward immediately to $targetNumber." | |
| } | |
| overflowDisableImmediate { | |
| $actionFriendly = "The Call Queue will not forward immediately to $targetNumber anymore. The previously configured Queue settings are active again." | |
| } | |
| timeOutUpdateNumber { | |
| $actionFriendly = "The Call Queue will forward to $targetNumber after the configured Timeout has been reached." | |
| } | |
| Default { | |
| } | |
| } | |
| $body = $body.Replace("actionPlaceholder","$actionFriendly") | |
| $runBookBody = @" | |
| { | |
| "actionType": "$action", | |
| "QueueId": "$callQueueId", | |
| "Number": "$targetNumber" | |
| } | |
| "@ | |
| Invoke-RestMethod -uri $uri -Method Post -ContentType "application/json" -Body $runBookBody | |
| # 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