In previous post Code – UCWA in C# – Part 03 of 05 we provided support to send IM.
In this post we will extend our prototype with support for Call via Work.
The Call via Work enhances our C# program – which can be deployed internal or external – with third party call capabilities.
Call via Work allows us to set-up a PSTN call between telephone number A and telephone number B, using the Lync Server 2013 or Skype for Business Server 2015 on premise back-end infrastructure.
And conversations are authenticated through AD credentials of an Enterprise Voice enabled on-premise user.
We will now use the botton part of the user interface with button_CallViaWork, textBox_CallViaWork_From, textBox_CallViaWork_To, textBox_CallViaWork_Subject and comboBox_CallViaWork_Priority.
As explained in previous post we receive available resources during logon, here we need two of them : the URL for phoneAudioInvitations and the OperationID.
ucwaStartPhoneAudio
1 |
<link rel="startPhoneAudio" href="/ucwa/oauth/v1/applications/103780543122/communication/phoneAudioInvitations"/> |
ucwaOperationID
1 |
<property name="6cc504b9-4363-4b09-bbdc-0544e42bf123">please pass this in a PUT request</property> |
To initiate the Call Via Work in C# we only need a single POST as shown below.
UCWA_Form01
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
private void button_CallViaWork_Click(object sender, EventArgs e) { listBox_Logging.Items.Clear(); CallViaWork_Step00(); } async public void CallViaWork_Step00() { string newNote = textBox_Note.Text; try { httpClient.DefaultRequestHeaders.Remove("Accept"); httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); string url_00 = ucwaApplications + ucwaStartPhoneAudio.Substring(27); // "https://lsweb2013-ext.realdolmen.com/ucwa/oauth/v1/applications/103780543122/communication/phoneAudioInvitations" Log("1",String.Format("Step 01 : POST : {0}", url_00)); string postdata_01 = "{\"phoneNumber\":\"" + "tel:" + textBox_CallViaWork_From.Text + "\",\"importance\":\"" + comboBox_CallViaWork_Priority.Text + "\",\"subject\":\"" + textBox_CallViaWork_Subject.Text + "\",\"to\":\"tel:" + textBox_CallViaWork_To.Text + "\",\"operationId\":\"" + ucwaOperationID + "\"}"; HttpContent json_01 = new StringContent(postdata_01); json_01.Headers.ContentType = new MediaTypeHeaderValue("application/json"); Log("3", String.Format(">> Request: {0}", "POST")); Log("3", String.Format(">> URL: {0}", url_00)); Log("3", String.Format("\r\n{0}", httpClient.DefaultRequestHeaders.ToString())); Log("3", String.Format(">> {0}=tel:{1}", "phoneNumber", textBox_CallViaWork_From.Text)); Log("3", String.Format(">> {0}={1}", "importance", comboBox_CallViaWork_Priority.Text)); Log("3", String.Format(">> {0}={1}", "subject", textBox_CallViaWork_Subject.Text)); Log("3", String.Format(">> {0}=tel:{1}", "to", textBox_CallViaWork_To.Text)); Log("3", String.Format(">> {0}={1}", "operationId", ucwaOperationID)); var res_00 = await httpClient.PostAsync(url_00, json_01); string res_00_request = res_00.RequestMessage.ToString(); string res_00_headers = res_00.Headers.ToString(); string res_00_status = res_00.StatusCode.ToString(); var res_00_content = await res_00.Content.ReadAsStringAsync(); Log("3", String.Format(">> Response: {0}", res_00_status)); Log("3", String.Format("{0}", res_00_headers)); Log("3", String.Format("\r\n{0}", res_00_content)); if (res_00_status == "Created") { Log("1",String.Format(">> Call via Work completed normally. tel:{0} > tel:{1}", textBox_CallViaWork_From.Text, textBox_CallViaWork_To.Text)); } else { Log("1",String.Format(">> Call via Work ended abnormally. tel{0} > tel:{1}", textBox_CallViaWork_From.Text, textBox_CallViaWork_To.Text)); } } catch (Exception ex) { Log("1",String.Format(">> Error in step 01. {0}", ex.InnerException.Message)); } } |
In the example we first call a GSM mobile user tel:+32491621278. That first call-leg is presenting the Enterprise Voice number of the authenticated AD user as calling number. When the first call is answered, a second call is set-up, in our example the second call is to tel:+3224023736 running Skype for Skype for Business client. Note that during that alert we see the subject as provided in the textBox_CallViaWork_Subject.
In case the second call is answered party A is connected to party B.
Since everything is running on the Lync Server 2013 or Skype for Business Server 2015 backbone, the infrastructure is providing information as usual, like missed call notifications.
If you need more information on Call via Work in Skype for Business Server 2015, have a look at the Microsoft Ignite 2015 session Planning and Deploying Call via Work for Enterprise PBX Users.
Also review the ucwa.lync.com to obtain more information on ongoing enhancements of UCWA (changed in Community Update 2 (CU2) and Skype for Business Server 2015).
Best Regards
Francis Missiaen
© 2016 by Francis Missiaen – this is not production code