Simple Connect To Conference
A simple inbound application that connects an answered inbound call to a named conference.
This application uses the connect to conference action to make an outbound call to a conference named "ATestConference". It sets a number of parameters that control how the call participates in the conference and what media is played to the conference before connecting to the inbound call.
Some audio (holdmusic.wav) is played to the inbound call until the outbound call is answered. Once answered and until the conference starts it is played some different audio (whileconfstopped.wav).
This sample requires one Extra Channel. Please configure your inbound service accordingly.
It also requires the wav files holdmusic.wav and whileconfstopped.wav to be available in the cloud media store.
This application uses the connect to conference action to make an outbound call to a conference named "ATestConference". It sets a number of parameters that control how the call participates in the conference and what media is played to the conference before connecting to the inbound call.
Some audio (holdmusic.wav) is played to the inbound call until the outbound call is answered. Once answered and until the conference starts it is played some different audio (whileconfstopped.wav).
This sample requires one Extra Channel. Please configure your inbound service accordingly.
It also requires the wav files holdmusic.wav and whileconfstopped.wav to be available in the cloud media store.
Uses actions: Connect To Conference, Play
{
"actions" :
[
{
"connect_to_conference":
{
"name" : "ATestConference",
"hold_media":
{
"play" :
{
"play_list" :
[
{
"file_to_play" : "holdmusic.wav"
}
]
}
},
"conference_participant" :
{
"talker" : true,
"start_on_entry" : true,
"destroy_on_exit" : false,
"beep_on_entry" : false,
"exit_digit" : "#",
"mute_digit" : "1",
"unmute_digit" : "2",
"while_stopped_media" :
{
"play" :
{
"play_list" :
[
{
"file_to_play" : "whileconfstopped.wav"
}
]
}
},
"name" :
{
"play" :
{
"play_list" :
[
{
"text_to_say" : "a member of the committee"
}
]
}
},
"has_joined_message" :
{
"play" :
{
"play_list" :
[
{
"text_to_say" : "has joined the conference"
}
]
}
},
"has_left_message" :
{
"play" :
{
"play_list" :
[
{
"text_to_say" : "has left the conference"
}
]
}
}
},
"next_page" :
{
"url" : "ConnectToConferenceNext"
}
}
},
{
"play" :
{
"play_list" :
[
{
"text_to_say" : "Sorry, I could not connect you to conference A Test Conference. Goodbye."
}
]
}
}
],
"token" : "my connect to conference instance id",
"api_version": "2.0"
}
{
"actions" :
[
{
"play" :
{
"play_list" :
[
{
"text_to_say" : "You are now out of the conference. Goodbye."
}
]
}
}
],
"token" : "my connect to conference instance id",
"api_version": "2.0"
}
{
[
],
"token" : "Error for Action: xxxx ActionIndex: xxxx Result: xxxx"
}
{
}
Implementing this sample as an ASP.Net Web application:
// CSharp Wrapper sample for the Aculab Telephony REST API.
//
// Simple ConnectToConference:
// A simple inbound application that connects an answered inbound call to a named conference.
// The application uses the connect to conference action to make an outbound call to a named conference.
// It sets a number of parameters that control how the call participates in the conference and what
// media is played to the conference before connecting to the inbound call.
using System;
using System.Collections.Generic;
using Aculab.Cloud.RestAPIWrapper;
public partial class SimpleConnectToConference : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Unpack the request
TelephonyRequest ourRequest = new TelephonyRequest(Request);
// Setup the actions
List<TelephonyAction> actions = new List<TelephonyAction>();
// Create the connect to conference action
ConnectToConference connectToConferenceAction = new ConnectToConference("ATestConference")
{
HoldMedia = Play.PlayFile("holdmusic.wav")
};
ConferenceParticipant participant = new ConferenceParticipant
{
Talker = true,
StartOnEntry = true,
DestroyOnExit = false,
BeepOnEntry = false,
ExitDigit = '#',
MuteDigit = '1',
UnmuteDigit = '2',
WhileStoppedMedia = Play.PlayFile("whileconfstopped.wav"),
Name = Play.SayText("a member of the committee"),
HasJoinedMessage = Play.SayText("has joined the conference"),
HasLeftMessage = Play.SayText("has left the conference")
};
connectToConferenceAction.Participant = participant;
connectToConferenceAction.NextPage = new WebPageRequest("ConnectToConferenceNext.aspx");
actions.Add(connectToConferenceAction);
// Add a message to play if the connect doesn't succeed
Play notConnectedMsgAction = Play.SayText("Sorry, I could not connect you to conference A Test Conference. Goodbye.");
actions.Add(notConnectedMsgAction);
// Respond
TelephonyResponse ourResponse = new TelephonyResponse(actions, "my connect to conference instance id");
ourResponse.ToHttpResponse(Response);
}
}
// CSharp Wrapper sample for the Aculab Telephony REST API.
//
// Simple ConnectToConference:
// ConnectToConferenceNext page
using System;
using System.Collections.Generic;
using Aculab.Cloud.RestAPIWrapper;
public partial class ConnectToConferenceNext : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Unpack the request
TelephonyRequest ourRequest = new TelephonyRequest(Request);
String token = ourRequest.InstanceInfo.Token;
// Setup the actions
List<TelephonyAction> actions = new List<TelephonyAction>();
actions.Add(Play.SayText("You are now out of the conference. Goodbye."));
// Respond
TelephonyResponse ourResponse = new TelephonyResponse(actions, token);
ourResponse.ToHttpResponse(Response);
}
}
using System;
using Aculab.Cloud.RestAPIWrapper;
public partial class ErrorPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Unpack the request
TelephonyRequest ourRequest = new TelephonyRequest(Request);
ErrorResult result = ourRequest.InstanceInfo.ErrorResult;
String token = String.Format("Action: {0}\nActionIndex: {1}\nResult: {2}",
result.Action, result.ActionIndex, result.Result);
// Respond
TelephonyResponse ourResponse = new TelephonyResponse(null, token);
ourResponse.ToHttpResponse(Response);
}
}
using System;
using Aculab.Cloud.RestAPIWrapper;
public partial class FinalPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Unpack the request
TelephonyRequest ourRequest = new TelephonyRequest(Request);
}
}
Implementing this sample as an ASP.Net Core Web application:
// ASP.NET Core CSharp Wrapper sample for the Aculab Telephony REST API.
//
// Simple ConnectToConference:
// A simple inbound application that connects an answered inbound call to a named conference.
// The application uses the connect to conference action to make an outbound call to a named conference.
// It sets a number of parameters that control how the call participates in the conference and what
// media is played to the conference before connecting to the inbound call.
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Aculab.Cloud.RestAPIWrapper;
using System.Net;
using System.Threading.Tasks;
namespace Aculab.Cloud.RESTAPI.NETCoreCSharpSamples.Controllers
{
[Route("SimpleConnectToConference")]
public class SimpleConnectToConferenceController : ControllerBase
{
// Process the GET or POST request, set up the actions and construct the json response.
[Route("FirstPage")]
[HttpGet]
[HttpPost]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> SimpleConnectToConference()
{
try
{
// Unpack the request
var telephonyRequest = await TelephonyRequest.UnpackRequestAsync(Request);
// Setup the actions required
List<TelephonyAction> actions = new List<TelephonyAction>();
// Create the connect to conference action
ConnectToConference connectToConferenceAction = new ConnectToConference("ATestConference")
{
HoldMedia = Play.PlayFile("holdmusic.wav")
};
ConferenceParticipant participant = new ConferenceParticipant()
{
Talker = true,
StartOnEntry = true,
DestroyOnExit = false,
BeepOnEntry = false,
ExitDigit = '#',
MuteDigit = '1',
UnmuteDigit = '2',
WhileStoppedMedia = Play.PlayFile("whileconfstopped.wav"),
Name = Play.SayText("a member of the committee"),
HasJoinedMessage = Play.SayText("has joined the conference"),
HasLeftMessage = Play.SayText("has left the conference")
};
connectToConferenceAction.Participant = participant;
connectToConferenceAction.NextPage = new WebPageRequest("SimpleConnectToConference/ConnectToConferenceNext");
actions.Add(connectToConferenceAction);
// Add a message to play if the connect doesn't succeed
Play notConnectedMsgAction = Play.SayText("Sorry, I could not connect you to conference A Test Conference. Goodbye.");
actions.Add(notConnectedMsgAction);
// Create response
TelephonyResponse ourResponse = new TelephonyResponse(actions, "my connect to conference instance id");
return new OkObjectResult(ourResponse.ToJson(this));
}
catch (ArgumentException)
{
return BadRequest();
}
catch (Exception e)
{
return StatusCode((int)HttpStatusCode.InternalServerError, e.Message);
}
}
}
}
// ASP.NET Core CSharp Wrapper sample for the Aculab Telephony REST API.
//
// Simple ConnectToConference:
// A simple inbound application that connects an answered inbound call to a named conference.
// The application uses the connect to conference action to make an outbound call to a named conference.
// It sets a number of parameters that control how the call participates in the conference and what
// media is played to the conference before connecting to the inbound call.
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Aculab.Cloud.RestAPIWrapper;
using System.Net;
using System.Threading.Tasks;
namespace Aculab.Cloud.RESTAPI.NETCoreCSharpSamples.Controllers
{
[Route("SimpleConnectToConference")]
public class SimpleConnectToConferenceController : ControllerBase
{
// Process the GET or POST request, set up the actions and construct the json response.
[Route("ConnectToConferenceNext")]
[HttpGet]
[HttpPost]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> ConnectToConferenceNext()
{
try
{
// Unpack the request
var telephonyRequest = await TelephonyRequest.UnpackRequestAsync(Request);
String token = telephonyRequest.InstanceInfo.Token;
// Setup the actions required
List<TelephonyAction> actions = new List<TelephonyAction>()
{
Play.SayText("You are now out of the conference. Goodbye.")
};
// Create response
TelephonyResponse ourResponse = new TelephonyResponse(actions, token);
return new OkObjectResult(ourResponse.ToJson(this));
}
catch (ArgumentException)
{
return BadRequest();
}
catch (Exception e)
{
return StatusCode((int)HttpStatusCode.InternalServerError, e.Message);
}
}
}
}
// ASP.NET Core CSharp Wrapper sample for the Aculab Telephony REST API.
using System;
using Microsoft.AspNetCore.Mvc;
using Aculab.Cloud.RestAPIWrapper;
using System.Net;
using System.Threading.Tasks;
namespace Aculab.Cloud.RESTAPI.NETCoreCSharpSamples.Controllers
{
public class RESTSampleController : ControllerBase
{
// Process the GET or POST request for the Error condition
[Route("ErrorPage")]
[HttpGet]
[HttpPost]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> ErrorPage()
{
try
{
// Unpack the request
var telephonyRequest = await TelephonyRequest.UnpackRequestAsync(Request);
ErrorResult result = telephonyRequest.InstanceInfo.ErrorResult;
String token = String.Format("Action: {0}\nActionIndex: {1}\nResult: {2}",
result.Action, result.ActionIndex, result.Result);
// Create response
TelephonyResponse ourResponse = new TelephonyResponse(null, token);
return new OkObjectResult(ourResponse.ToJson(this));
}
catch (ArgumentException)
{
return BadRequest();
}
catch (Exception e)
{
return StatusCode((int)HttpStatusCode.InternalServerError, e.Message);
}
}
}
}
// ASP.NET Core CSharp Wrapper sample for the Aculab Telephony REST API.
using System;
using Microsoft.AspNetCore.Mvc;
using Aculab.Cloud.RestAPIWrapper;
using System.Net;
using System.Threading.Tasks;
namespace Aculab.Cloud.RESTAPI.NETCoreCSharpSamples.Controllers
{
public class RESTSampleController : ControllerBase
{
// Process the GET or POST request for the Final Page
[Route("FinalPage")]
[HttpGet]
[HttpPost]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
public async Task<IActionResult> FinalPage()
{
try
{
// Unpack the request
var telephonyRequest = await TelephonyRequest.UnpackRequestAsync(Request);
String token = telephonyRequest.InstanceInfo.Token;
// Create response
// Only very limited actions can be returned here
TelephonyResponse ourResponse = new TelephonyResponse(null, token);
return new OkObjectResult(ourResponse.ToJson(this));
}
catch (ArgumentException)
{
return BadRequest();
}
catch (Exception e)
{
return StatusCode((int)HttpStatusCode.InternalServerError, e.Message);
}
}
}
}
Implemented as ASP.Net Web App:
' Visual Basic Wrapper sample for the Aculab Telephony REST API.
'
' The first page for the Simple Connect To Conference sample:
' A simple inbound application that connects an answered inbound call to a named conference.
' The application uses the connect to conference action to make an outbound call to a named conference.
' It sets a number of parameters that control how the call participates in the conference and what
' media is played to the conference before connecting to the inbound call.
Imports System.Collections.Generic
Imports Aculab.Cloud.RestAPIWrapper
Partial Class SimpleConnectToConference
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Unpack the request
Dim ourRequest As TelephonyRequest = New TelephonyRequest(Request)
' Setup the actions
Dim actions As List(Of TelephonyAction) = New List(Of TelephonyAction)
' Create the connect to conference action
Dim connectToConferenceAction As ConnectToConference = New ConnectToConference("ATestConference")
connectToConferenceAction.HoldMedia = Play.PlayFile("holdmusic.wav")
Dim participant As ConferenceParticipant = New ConferenceParticipant()
participant.Talker = True
participant.StartOnEntry = True
participant.DestroyOnExit = False
participant.BeepOnEntry = False
participant.ExitDigit = "#"
participant.MuteDigit = "1"
participant.UnmuteDigit = "2"
participant.WhileStoppedMedia = Play.PlayFile("whileconfstopped.wav")
participant.Name = Play.SayText("a member of the committee")
participant.HasJoinedMessage = Play.SayText("has joined the conference")
participant.HasLeftMessage = Play.SayText("has left the conference")
connectToConferenceAction.Participant = participant
connectToConferenceAction.NextPage = New WebPageRequest("ConnectToConferenceNext.aspx")
actions.Add(connectToConferenceAction)
' Add a message to play if the connect doesn't succeed
Dim notConnectedMsgAction As Play = Play.SayText("Sorry, I could not connect you to conference A Test Conference. Goodbye.")
actions.Add(notConnectedMsgAction)
' Respond
Dim ourResponse As TelephonyResponse = New TelephonyResponse(actions, "my connect to conference instance id")
ourResponse.ToHttpResponse(Response)
End Sub
End Class
' Visual Basic Wrapper sample for the Aculab Telephony REST API.
'
' A page from the Simple Connect To Conference sample:
' This is called when the caller exits the conference. It plays a
' final goodbye message.
Imports System.Collections.Generic
Imports Aculab.Cloud.RestAPIWrapper
Partial Class ConnectToConferenceNext
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Unpack the request
Dim ourRequest As TelephonyRequest = New TelephonyRequest(Request)
Dim token As String = ourRequest.InstanceInfo.Token
' Setup the actions
Dim actions As List(Of TelephonyAction) = New List(Of TelephonyAction)
actions.Add(Play.SayText("You are now out of the conference. Goodbye."))
' Respond
Dim ourResponse As TelephonyResponse = New TelephonyResponse(actions, token)
ourResponse.ToHttpResponse(Response)
End Sub
End Class
' Visual Basic Wrapper sample for the Aculab Telephony REST API.
'
' A generic error page for all the samples.
Imports Aculab.Cloud.RestAPIWrapper
Partial Class ErrorPage
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Unpack the request
Dim ourRequest As TelephonyRequest = New TelephonyRequest(Request)
Dim result As ErrorResult = ourRequest.InstanceInfo.ErrorResult
Dim token As String = String.Format("Action: {0}\nActionIndex: {1}\nResult: {2}", _
result.Action, result.ActionIndex, result.Result)
' Respond
Dim ourResponse As TelephonyResponse = New TelephonyResponse(token)
ourResponse.ToHttpResponse(Response)
End Sub
End Class
' Visual Basic Wrapper sample for the Aculab Telephony REST API.
'
' A generic final page for all the samples:
Imports Aculab.Cloud.RestAPIWrapper
Partial Class FinalPage
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Unpack the request
Dim ourRequest As TelephonyRequest = New TelephonyRequest(Request)
' Do application tidying up
' ...
End Sub
End Class
Implemented as Java Servlets:
// Java Servlet sample for the Aculab Telephony REST API.
//
// Simple ConnectToConference:
// A simple inbound application that connects an answered inbound call to a named conference.
// The application uses the connect to conference action to make an outbound call to a named conference.
// It sets a number of parameters that control how the call participates in the conference and what
// media is played to the conference before connecting to the inbound call.
package com.aculab.telephonyrestapi.samples;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.aculab.telephonyrestapi.*;
public class SimpleConnectToConference extends HttpServlet
{
private static final long serialVersionUID = -6560113572458758331L;
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
handleRequest(request, response);
}
@Override
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
handleRequest(request, response);
}
private void handleRequest(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
// Unpack the request
TelephonyRequest ourRequest = new TelephonyRequest(request);
// Set up the actions
List<TelephonyAction> actions = new ArrayList<TelephonyAction>();
// Create the connect to conference action
ConnectToConference connectToConferenceAction = new ConnectToConference("ATestConference");
connectToConferenceAction.setHoldMedia(Play.playFile("holdmusic.wav"));
ConferenceParticipant participant = new ConferenceParticipant();
participant.setTalker(true);
participant.setStartOnEntry(true);
participant.setDestroyOnExit(false);
participant.setBeepOnEntry(false);
participant.setExitDigit('#');
participant.setMuteDigit('1');
participant.setUnmuteDigit('2');
participant.setWhileStoppedMedia(Play.playFile("whileconfstopped.wav"));
participant.setName(Play.sayText("a member of the committee"));
participant.setHasJoinedMessage(Play.sayText("has joined the conference"));
participant.setHasLeftMessage(Play.sayText("has left the conference"));
connectToConferenceAction.setParticipant(participant);
connectToConferenceAction.setNextPage(new WebPageRequest("ConnectToConferenceNext"));
actions.add(connectToConferenceAction);
// Add a message to play if the connect doesn't succeed
Play notConnectedMsgAction = Play.sayText("Sorry, I could not connect you to conference A Test Conference. Goodbye.");
actions.add(notConnectedMsgAction);
// Respond
TelephonyResponse ourResponse = new TelephonyResponse(actions, "my connect to conference instance id");
ourResponse.setHttpServletResponse(response);
}
}
// Java Servlet sample for the Aculab Telephony REST API.
//
// Simple Connect Sample
package com.aculab.telephonyrestapi.samples;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.aculab.telephonyrestapi.*;
public class ConnectToConferenceNext extends HttpServlet
{
private static final long serialVersionUID = -1226287713741198205L;
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
handleRequest(request, response);
}
@Override
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
handleRequest(request, response);
}
private void handleRequest(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
// Unpack the request
TelephonyRequest ourRequest = new TelephonyRequest(request);
String token = ourRequest.getInstanceInfo().getToken();
// Set up the actions
List<TelephonyAction> actions = new ArrayList<TelephonyAction>();
actions.add(Play.sayText("You are now out of the conference. Goodbye."));
// Respond
TelephonyResponse ourResponse = new TelephonyResponse(actions, token);
ourResponse.setHttpServletResponse(response);
}
}
// Java Servlet sample for the Aculab Telephony REST API.
//
package com.aculab.telephonyrestapi.samples;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.aculab.telephonyrestapi.*;
public class ErrorPage extends HttpServlet
{
private static final long serialVersionUID = -4842873371047361437L;
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
handleRequest(request, response);
}
@Override
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
handleRequest(request, response);
}
private void handleRequest(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
// Unpack the request
TelephonyRequest ourRequest = new TelephonyRequest(request);
ErrorResult result = ourRequest.getInstanceInfo().getErrorResult();
String token = String.format("Action: %s\nActionIndex: %d\nResult: %s", result.getAction(), result.getActionIndex(), result.getResult());
// Respond
List<TelephonyAction> actions = new ArrayList<TelephonyAction>();
TelephonyResponse ourResponse = new TelephonyResponse(actions, token);
ourResponse.setHttpServletResponse(response);
}
}
// Java Servlet sample for the Aculab Telephony REST API.
//
package com.aculab.telephonyrestapi.samples;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import java.io.IOException;
import com.aculab.telephonyrestapi.*;
public class FinalPage extends HttpServlet
{
private static final long serialVersionUID = 5940620014313056844L;
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
handleRequest(request, response);
}
@Override
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
handleRequest(request, response);
}
private void handleRequest(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
// Unpack the request
TelephonyRequest ourRequest = new TelephonyRequest(request);
}
}
Implemented as a Flask web application:
@app.route('/SimpleConnectToConference', methods=['GET','POST'])
def handle_SimpleConnectToConference():
my_request = TelephonyRequest(request)
app_inst_id = my_request.get_application_instance_id()
print("SimpleConnectToConference: app_inst_id='{}'".format(app_inst_id))
# On your inbound service configuration page, set the first page entry to point to this page
# e.g., http://<ip address>:<port>/first_page.
# To connect to a conference your inbound service will require one Extra Channel, configure
# the service to have one Extra Channel.
my_conference = ConnectToConference('ATestConference')
my_conference.set_hold_media(Play(file_to_play='holdmusic.wav'))
my_conference.set_conference_participant(ConferenceParticipant(talker = True,
start_on_entry = True,
destroy_on_exit = False,
beep_on_entry = False,
mute_digit = '1',
unmute_digit = '2',
exit_digit = '#',
while_stopped_media=Play(file_to_play='whileconfstopped.wav'),
name=Play(text_to_say='a member of the committee'),
has_joined_message=Play(text_to_say='has joined the conference'),
has_left_message=Play(text_to_say='has left the conference')))
my_conference.set_next_page(WebPage(url='ConnectToConferenceNext'))
list_of_actions = []
list_of_actions.append(my_conference)
list_of_actions.append(Play(text_to_say='Sorry, I could not connect you to conference A Test Conference. Goodbye.'))
my_response = TelephonyResponse(list_of_actions, token='my connect to conference instance id')
return Response(response=my_response.get_json(), content_type='application/json;charset=utf-8')
@app.route('/ConnectToConferenceNext', methods=['GET','POST'])
def handle_ConnectToConferenceNext():
my_request = TelephonyRequest(request)
my_token = my_request.get_token()
list_of_actions = []
list_of_actions.append(Play(text_to_say='You are now out of the conference. Goodbye.'))
my_response = TelephonyResponse(list_of_actions, my_token)
return Response(response=my_response.get_json(), content_type='application/json;charset=utf-8')
@app.route('/ErrorPage', methods=['GET','POST'])
def handle_ErrorPage():
my_request = TelephonyRequest(request)
token = my_request.get_token()
app_inst_id = my_request.get_application_instance_id()
error_result_dict = my_request.get_error_result()
action_string = error_result_dict.get('action', "?")
result_string = error_result_dict.get('result', "?")
print("ErrorPage: app_inst_id='{}' token='{}' action='{}' result='{}'".format(app_inst_id, token, action_string, result_string))
my_response = TelephonyResponse([Play(text_to_say='An error has occurred')])
return Response(response=my_response.get_json(), content_type='application/json;charset=utf-8')
@app.route('/FinalPage', methods=['GET','POST'])
def handle_FinalPage():
# The FinalPage handler follows the guidelines on:
# https://www.aculab.com/cloud/voice-and-fax-apis/rest-api/rest-api-version-2/writing-a-rest-application
# The guidelines are:
# "Your final page should return an empty response, a 204 is preferable, but empty JSON is acceptable."
my_request = TelephonyRequest(request)
token = my_request.get_token()
app_inst_id = my_request.get_application_instance_id()
print("FinalPage: app_inst_id='{}' token='{}'".format(app_inst_id, token))
empty_json = '{}'.encode('utf-8')
return Response(response=empty_json, status=204, content_type='application/json;charset=utf-8')
<?php
header("Content-Type: application/json; charset=UTF-8");
require __DIR__ . "/../../autoload.php";
use \Aculab\TelephonyRestAPI\Response;
use \Aculab\TelephonyRestAPI\Play;
use \Aculab\TelephonyRestAPI\ConnectToConference;
use \Aculab\TelephonyRestAPI\ConferenceParticipantConfiguration;
$response = new Response();
$response->setToken('my connect to conference instance id');
// Create the connect to conference action
$connect_to_conference = new ConnectToConference('ATestConference');
$connect_to_conference->setHoldMedia(Play::playFile('holdmusic.wav'));
$connect_to_conference->setNextPage('ConnectToConferenceNext.php');
$participant_config = new ConferenceParticipantConfiguration();
$participant_config->setTalker(true);
$participant_config->setStartOnEntry(true);
$participant_config->setDestroyOnExit(false);
$participant_config->setBeepOnEntry(false);
$participant_config->setExitDigit('#');
$participant_config->setMuteDigit('1');
$participant_config->setUnmuteDigit('2');
$participant_config->setWhileStoppedMedia(Play::playFile('whileconfstopped.wav'));
$participant_config->setName(Play::sayText('a member of the committee'));
$participant_config->setHasJoinedMessage(Play::sayText('has joined the conference'));
$participant_config->setHasLeftMessage(Play::sayText('has left the conference'));
$connect_to_conference->setParticipantConfiguration($participant_config);
$response->addAction($connect_to_conference);
// Add a message to play if the connect to conference doesn't succeed
$play = new Play();
$play->addText('Sorry, I could not connect you to conference A Test Conference. Goodbye.');
$response->addAction($play);
print $response;
<?php
header("Content-Type: application/json; charset=UTF-8");
require __DIR__ . "/../../autoload.php";
use \Aculab\TelephonyRestAPI\InstanceInfo;
use \Aculab\TelephonyRestAPI\Response;
use \Aculab\TelephonyRestAPI\Play;
$info = InstanceInfo::getInstanceInfo();
$response = new Response();
$response->setToken($info->getToken());
$play = new Play();
$play->addText('You are now out of the conference. Goodbye.');
$response->addAction($play);
print $response;
<?php
header("Content-Type: application/json; charset=UTF-8");
require __DIR__ . "/../../autoload.php";
use Aculab\TelephonyRestAPI\Play;
use Aculab\TelephonyRestAPI\Response;
use Aculab\TelephonyRestAPI\InstanceInfo;
$info = InstanceInfo::getInstanceInfo();
$error = $info->getErrorResult();
$action = $error->getAction();
$desc = $error->getResult();
if (!is_null($action)) {
error_log("Error from action \"$action\" with result:" . PHP_EOL . "$desc" . PHP_EOL);
} else {
error_log("Error result:" . PHP_EOL . "$desc" . PHP_EOL);
}
$response = new Response();
$response->setToken('Error');
$play = new Play();
$play->addText('An error has occurred.');
$response->addAction($play);
print $response;
<?php
require __DIR__ . "/../../autoload.php";
http_response_code(204);
header("Content-Type: application/json; charset=UTF-8");
use Aculab\TelephonyRestAPI\InstanceInfo;
$info = InstanceInfo::getInstanceInfo();
$call = $info->getThisCallInfo();
$callid = $call->getCallId();
$duration = $call->getSecondsCallDuration();
error_log("This call id: $callid" . PHP_EOL . "This call duration: $duration" . PHP_EOL);