Skip to content

Latest commit

 

History

History
96 lines (72 loc) · 2.9 KB

04.calls.md

File metadata and controls

96 lines (72 loc) · 2.9 KB

Calls

Initiating an IVR Call Immediately

var client = new CallfireClient("api-login", "api-password", CallfireClients.Rest);
var callClient = client.Call;

var ivrBroadcastConfig = new CfIvrBroadcastConfig();
ivrBroadcastConfig.FromNumber = "15551231234";
ivrBroadcastConfig.DialplanXml = string.Format("{0} {1}", "<dialplan><play type=\"tts\">Congratulations!",
 "You have successfully configured a CallFire I V R.</play></dialplan>");

var toNumber = new CfToNumber();
toNumber.Value = "15551231235";

var sendCall = new CfSendCall();
sendCall.Type = CfBroadcastType.Ivr;
sendCall.ToNumber = new[] { toNumber };
sendCall.Item = ivrBroadcastConfig;

var id = callClient.SendCall(sendCall);

Initiating a Voice Call Immediately

var client = new CallfireClient("api-login", "api-password", CallfireClients.Rest);
var callClient = client.Call;

var soundId = 123456789; // Some existing sound ID

var voiceBroadcastConfig = new CfVoiceBroadcastConfig();
voiceBroadcastConfig.FromNumber = "15551231234";
voiceBroadcastConfig.AnsweringMachineConfig = CfAnsweringMachineConfig.AmAndLive;
voiceBroadcastConfig.Item = soundId;

var toNumber = new CfToNumber();
toNumber.Value = "15551231235";

var sendCall = new CfSendCall();
sendCall.Type = CfBroadcastType.Voice;
sendCall.Item = voiceBroadcastConfig;
sendCall.ToNumber = new[] { toNumber };

var id = callClient.SendCall(sendCall);

Sending calls with multiple labels

var client = new CallfireClient("api-login", "api-password", CallfireClients.Rest);
var callClient = client.Call;

var ivrBroadcastConfig = new CfIvrBroadcastConfig();
ivrBroadcastConfig.FromNumber = "15551231234";
ivrBroadcastConfig.DialplanXml = string.Format("{0} {1}", "<dialplan><play type=\"tts\">Congratulations!",
 "You have successfully configured a CallFire I V R.</play></dialplan>");

var toNumber = new CfToNumber();
toNumber.Value = "15551231235";

var sendCall = new CfSendCall();
sendCall.Type = CfBroadcastType.Ivr;
sendCall.ToNumber = new[] { toNumber };
sendCall.Item = ivrBroadcastConfig;
//Note: label values with spaces can't be used for REST api calls, only for SOAP (limitation)  
sendCall.Labels = new string[] { "Test_Label_1", "Test_Label_2" };

var id = callClient.SendCall(sendCall);

List Incoming Calls For a Number

var client = new CallfireClient("api-login", "api-password", CallfireClients.Rest);
var callClient = client.Call;

var actionQuery = new CfActionQuery();
actionQuery.Inbound = True;
actionQuery.ToNumber = "15551231234";

var cfCallQueryResult = callClient.QueryCalls(actionQuery);

if (cfCallQueryResult.Calls != null)
{
	var callList = new string[cfCallQueryResult.Calls.Count()];
	for (var i = 0; i < cfCallQueryResult.Calls.Count(); i++)
	{
		var cfCall = cfCallQueryResult.Calls[i];
		callList[i] = string.Format("Created: {0} FromNumber: {1} ToNumber: {2}",
			cfCall.Created.ToString(), cfCall.FromNumber, cfCall.ToNumber.Value);
	}
}