Skip to content

Instantly share code, notes, and snippets.

@callemall
Last active December 20, 2015 11:29
Show Gist options
  • Save callemall/6123581 to your computer and use it in GitHub Desktop.
Save callemall/6123581 to your computer and use it in GitHub Desktop.
This example creates and launches a simple text-to-speech broadcast using the ExtCreateBroadcast function.
# ===========================================================================================================================
#
# Send a voice-only broadcast (an announcement) with the name 'Test of Emergency' to the Emergency contacts group outside of the
# calling window. The broadcast should launch immdediately with the text-to-speech message of 'Please call the emergency bridge
# line as soon as possible, we are having an outage.'
#
# To do this, we'll make use of the ExtCreateBroadcast_AD function (shown below), passing it six parameters:
#
# ExtCreateBroadcast_AD 'Test of Emergency' Emergency 1 0 '' 'Please call the emergency bridge line as soon as possible, we are having an outage'
#
# The ExtCreateBroadcast_AD function's full list of parameters is described in the example code below.
#
# ============================================================================================================================
function ExtCreateBroadcast_AD
(
# The name of the Broadcast
[String] $broadcastName,
# The Active Directory "group" to call
[String] $ADGroupName,
# Broadcast Type 1-announcement, 2-survey, 3-SMS/Text, 4-SMS to opt-ins, Voice to remaining, 5-SMS to opt-ins voice to all
[String] $broadcastType = "1",
# CheckCallingWindow 0-DO NOT CHECK, 1-Only allow between default hours
[String] $checkCallingWindow = "0",
# When to send, leave empty for immediate "" else format = "12/25/2011 7:30 AM"
[String] $launchDateTime = "",
# Text to speak, send empty to ignore ""
[String] $TTSText = "",
# Text to speak for non live answer, send empty to ignore ""
[String] $TTSTextVM = "",
# Message ID to use
[String] $messageID = "",
# Message ID to use
[String] $messageIDVM = "",
# BC Type 3/4/5 the SMS message to send
[String] $smsMsg = "",
# Coming soon send email when BC completes
[String] $notifyEmail =""
)
{
[String] $username = '999111999'
[String] $pin = '9991'
[String] $callerID = "9725551212"
$URL = "http://staging-api.call-em-all.com/webservices/ceaapi_v2.asmx"
$Action = "http://call-em-all.com/ExtCreateBroadcast"
$phoneNumberSource = "3"
$commaDelimitedPhoneNumbers = $(GetADMembers $ADGroupName)
[XML] $SOAPRequest = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ExtCreateBroadcast xmlns="http://call-em-all.com/">
<myRequest>
<username>' + $username +'</username>
<pin>' + $pin + '</pin>
<TTSText>' + $TTSText + '</TTSText>
<TTSTextVM>' + $TTSTextVM + '</TTSTextVM>
<broadcastName>' + $broadcastName + '</broadcastName>
<broadcastType>' + $broadcastType + '</broadcastType>
<callerID>' + $callerID + '</callerID>
<checkCallingWindow>' + $checkCallingWindow + '</checkCallingWindow>
<phoneNumberSource>' + $phoneNumberSource + '</phoneNumberSource>
<commaDelimitedPhoneNumbers>' + $commaDelimitedPhoneNumbers + '</commaDelimitedPhoneNumbers>
<launchDateTime>' + $launchDateTime + '</launchDateTime>
<listID>' + $listID + '</listID>
<messageID>' + $messageID + '</messageID>
<messageIDVM>' + $messageIDVM + '</messageIDVM>
<notifyEmail>' + $notifyEmail + '</notifyEmail>
<smsMsg>string</smsMsg>
</myRequest>
</ExtCreateBroadcast>
</soap:Body>
</soap:Envelope>'
write-host "Sending SOAP Request To Server: $URL"
write-host "SOAP Request : " $SOAPRequest.Envelope.Body.ExtCreateBroadcast.myRequest
$soapWebRequest = [System.Net.WebRequest]::Create($URL)
$soapWebRequest.Headers.Add("SOAPAction", $Action)
$soapWebRequest.ContentType = "text/xml;charset=`"utf-8`""
$soapWebRequest.Accept = "text/xml"
$soapWebRequest.Method = "POST"
write-host "Initiating Send."
$requestStream = $soapWebRequest.GetRequestStream()
$SOAPRequest.Save($requestStream)
$requestStream.Close()
write-host "Send Complete, Waiting For Response."
$resp = $soapWebRequest.GetResponse()
$responseStream = $resp.GetResponseStream()
$soapReader = [System.IO.StreamReader]($responseStream)
$ReturnXml = [Xml] $soapReader.ReadToEnd()
$responseStream.Close()
write-host "============================================"
write-host "errorCode " $ReturnXml.Envelope.Body.ExtCreateBroadcastResponse.ExtCreateBroadcastResult.errorCode
write-host "errorMessage " $ReturnXml.Envelope.Body.ExtCreateBroadcastResponse.ExtCreateBroadcastResult.errorMessage
write-host "============================================"
write-host "broadcastID " $ReturnXml.Envelope.Body.ExtCreateBroadcastResponse.ExtCreateBroadcastResult.broadcastID
write-host "goodRecordCountOnFile " $ReturnXml.Envelope.Body.ExtCreateBroadcastResponse.ExtCreateBroadcastResult.goodRecordCountOnFile
write-host "============================================================================"
write-host ""
write-host " If you did not specify a message/audio ID or provide Text-To-Speech info"
write-host " then you need to call " $ReturnXml.Envelope.Body.ExtCreateBroadcastResponse.ExtCreateBroadcastResult.tollFreeNumber " and use recording ID : " $ReturnXml.Envelope.Body.ExtCreateBroadcastResponse.ExtCreateBroadcastResult.messageRecordingID
write-host ""
write-host "============================================================================"
write-host "tollFreeNumber " $ReturnXml.Envelope.Body.ExtCreateBroadcastResponse.ExtCreateBroadcastResult.tollFreeNumber
write-host "messageRecordingID " $ReturnXml.Envelope.Body.ExtCreateBroadcastResponse.ExtCreateBroadcastResult.messageRecordingID
write-host "============================================"
return [xml] $ReturnXml
}
@prasadrahul
Copy link

Hello gist testing tool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment