Relay SDK for .NET
Getting Started
The Relay SDK for .NET enables .NET developers to connect and use SignalWire's Relay APIs within their own .NET code. Our Relay SDK allows developers to build or add robust and innovative communication services to their applications.
The Relay SDK for .NET is easy to use and only takes a few minute to setup and get running.
Source Code: signalwire/signalwire-dotnet
Support: SignalWire Community Slack Channel
Installation
Install the package for a .NET Core project using NUGET:
dotnet add package signalwire-dotnet
Or you can install the package through Visual Studio's NUGET package manager, simply install the signalwire-dotnet
package to your project.
Minimum Requirements
The .NET SDK may be used with .NET Framework 4.6.1 or greater or .NET Core 2.1 or greater.
Using the SDK
The .NET SDK can be used to get up and running with Relay quickly and easily. In order to use the .NET client, you must get your project and token from your SignalWire dashboard.
There are a few ways to get started, depending on your needs: SignalWire.Relay.Consumer
, SignalWire.Relay.Task
, and SignalWire.Relay.Client
.
Relay Consumer
A SignalWire.Relay.Consumer
creates a long running process, allowing you to respond to incoming requests and events in realtime. Relay Consumers abstract all the setup of connecting to Relay and automatically dispatches workers to handle requests; so you can concentrate on writing your code without having to worry about multi-threading or blocking, everything just works. Think of Relay Consumers like a background worker system for all your calling and messaging needs.
Relay Consumers can scale easily, simply by running multiple instances of your SignalWire.Relay.Consumer
process. Each event will only be delivered to a single consumer, so as your volume increases, just scale up! This process works well whether you are using Docker Swarm, a Procfile on Heroku, your own webserver, and most other environments.
Setting up a new consumer is the easiest way to get up and running.
using SignalWire.Relay;
using SignalWire.Relay.Calling;
using System;
using System.Collections.Generic;
namespace Example
{
class ExampleConsumer : Consumer
{
protected override void Setup()
{
Project = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
Token = "PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
Contexts = new List<string> { "test" };
}
protected override void OnIncomingCall(Call call)
{
AnswerResult resultAnswer = call.Answer();
if (!resultAnswer.Successful) return;
call.PlayTTS("Welcome to SignalWire!");
call.Hangup();
}
}
class Program
{
public static void Main()
{
new ExampleConsumer().Run();
}
}
}
Learn more about Relay Consumers
Relay Task
A SignalWire.Relay.RelayTask
is simple way to send jobs to your SignalWire.Relay.Consumer
from a short lived process, like a web framework. Relay Tasks allow you to pass commands down to your Consumers without blocking your short lived request. Think of a Relay Task as a way to queue a job for your background workers to processes asynchronously.
For example, if you wanted to make an outbound call and play a message when your user clicks a button on your web application, since Relay is a realtime protocol and relies on you to tell it what to do in realtime, if you did this within your web application, your web server would block until the call was finished... this may take a long time! Instead, simply create a new Relay Task. This task will be handled by a running Relay Consumer process and your web application can respond back to your user immediately.
RelayTask.Deliver(validHost, validProjectID, validToken, validContext, new JObject {
["number_to_call"] = "+1555XXXXXXX",
["message_to_play"] = "We have a message for you",
});
Relay Client
SignalWire.Relay.Client
is a lower level object, giving you a basic connection to Relay but that is all. It is best used when you are creating a script only concerned with sending outbound requests or you want complete control over the Relay connection yourself.
Setting up a new client and make an outbound call.
using SignalWire.Relay;
using SignalWire.Relay.Calling;
using System;
using System.Threading.Tasks;
namespace Example
{
internal class Program
{
public static void Main()
{
using (Client client = new Client("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"))
{
// Assign callbacks
client.OnReady += c =>
{
// This callback cannot block, so create a threaded task
Task.Run(() =>
{
DialResult resultDial = client.Calling.DialPhone("+1XXXXXXXXXX", "+1YYYYYYYYYY");
if (resultDial.Successful)
{
// Your call has been answered, use resultDial.Call to access it
}
});
};
// Connect the client
client.Connect();
// Prevent exit until a key is pressed
Console.Write("Press any key to exit...");
Console.ReadKey(true);
}
}
}
}
Learn more about Relay Clients
Contexts
Relay uses Contexts as a simple way to separate events to specific consumers, allowing you to write consumers for specific types of calls or messages or scale them independently. A Context is simply a named string, that allows you to categorize requests. When creating outbound requests, or configuring phone numbers for inbound requests, you can specify the context; Relay will then deliver that call or event to Consumers that are configured to listen for that context.
For example, you could have a customer support phone number configured to send to Relay with the support
context, and a personal number configured with personal
context. Relay would deliver these events to any Consumer listening for those contexts. This gives you a lot of control in how messages are delivered to your Consumers, allowing you to write Consumer classes specific to the context, scale them independently, or separate traffic based on your own business rules.
API Reference
SignalWire.Relay.Consumer
A Relay Consumer is a simple application framework that provides a shell for creating independent consumers of the Relay SDK. Relay Consumers abstract all the setup of connecting to Relay and automatically dispatch workers to handle requests. Consumers will receive requests and delegate them to their own worker thread, allowing you to focus on your business logic without having to worry about multi-threading or blocking, everything just works. Think of Relay Consumers like a background worker system for all your calling and messaging needs.
Creating Consumers
A Relay Consumer is a simple application framework, customized by specifying contexts and event handlers to respond to incoming events.
A consumer has 2 required properties: project
, token
, and usually requires at least one contexts
for incoming events. Project and Token are used to authenticate your Consumer to your SignalWire account. Contexts are a list of contexts you want this Consumer to listen for. Learn more about Contexts.
A consumer is created by inheriting the Consumer
type, and then overriding the available methods. It is then executed by initializing and calling the Run
method on it.
You can optionally add code to the Setup
method if you need to do any initialization work before processing messages. This is useful to do any one-off work that you wouldn't want to do for each and every event, such as setting up logging or connecting to a datastore.
using SignalWire.Relay;
using SignalWire.Relay.Calling;
using System;
using System.Collections.Generic;
namespace Example
{
internal class ExampleConsumer : Consumer
{
protected override void Setup()
{
Project = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
Token = "PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
Contexts = new List<string> { "test" };
// Do additional setup here
}
protected override void OnIncomingCall(Call call)
{
AnswerResult resultAnswer = call.Answer();
call.PlayTTS("Welcome to SignalWire!");
call.Hangup();
}
}
internal class Program
{
public static void Main()
{
new ExampleConsumer().Run();
}
}
}
Event Handlers
Event handlers are where you will write most of your code. They are executed when your consumer receives a matching event for the contexts specified by your Consumer.
OnIncomingCall
Executed when you receive an inbound call, passes in the inbound Call
object.
Available In:
using SignalWire.Relay;
using SignalWire.Relay.Calling;
using System;
using System.Collections.Generic;
namespace Example
{
internal class IncomingCallConsumer : Consumer
{
protected override void Setup()
{
Project = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
Token = "PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
Contexts = new List<string> { "test" };
}
protected override void OnIncomingCall(Call call)
{
AnswerResult resultAnswer = call.Answer();
call.PlayTTS("Welcome to SignalWire!");
call.Hangup();
}
}
internal class Program
{
public static void Main()
{
new IncomingCallConsumer().Run();
}
}
}
Ready
Executed when the Consumer has connected and is ready to make Relay requests.
Available In:
using SignalWire.Relay;
using SignalWire.Relay.Messaging;
using System;
using System.Collections.Generic;
namespace Example
{
internal class ReadyConsumer : Consumer
{
protected override void Setup()
{
Project = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
Token = "PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
Contexts = new List<string> { "test" };
}
protected override void Ready(Client client)
{
Console.WriteLine("Client ready, sending message...");
SendResult result = client.Messaging.Send(
"incoming_context",
"+1XXXXXXXXXX",
"+1YYYYYYYYYY",
new SendSource("Hello from SignalWire!"));
if (result.Successful)
{
Console.WriteLine("Send was successful");
}
}
}
internal class Program
{
public static void Main()
{
new ReadyConsumer().Run();
}
}
}
OnTask
Executed when a task is received, passes in the RelayTask
object.
Available In:
using SignalWire.Relay;
using SignalWire.Relay.Messaging;
using System;
using System.Collections.Generic;
namespace Example
{
internal class TaskConsumer : Consumer
{
protected override void Setup()
{
Project = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
Token = "PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
Contexts = new List<string> { "test" };
}
protected override void OnTask(RelayTask task)
{
Console.WriteLine("Task successfully received for project ID {0} at {1} with message '{2}'", task.ProjectID, task.Timestamp, task.Message.ToString());
}
}
internal class Program
{
public static void Main()
{
new TaskConsumer().Run();
}
}
}
OnIncomingMessage
Executed when you receive an inbound message, passes in the inbound Message
object.
Available In:
using SignalWire.Relay;
using SignalWire.Relay.Messaging;
using System;
using System.Collections.Generic;
namespace Example
{
internal class IncomingMessageConsumer : Consumer
{
protected override void Setup()
{
Project = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
Token = "PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
Contexts = new List<string> { "test" };
}
protected override void OnIncomingMessage(Message message)
{
if (message.Body?.StartsWith("Hello") == true) {
// ...
}
}
}
internal class Program
{
public static void Main()
{
new IncomingMessageConsumer().Run();
}
}
}
OnMessageStateChange
Executed when a message state change event comes through. Passes in the Message
object.
Available In:
using SignalWire.Relay;
using SignalWire.Relay.Messaging;
using System;
using System.Collections.Generic;
namespace Example
{
internal class MessageStateChangeConsumer : Consumer
{
protected override void Setup()
{
Project = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
Token = "PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
Contexts = new List<string> { "test" };
}
protected override void OnMessageStateChange(Message message)
{
if (message.ID == "YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY") {
// ...
}
}
}
internal class Program
{
public static void Main()
{
new MessageStateChangeConsumer().Run();
}
}
}
Cleaning Up on Exit
When a Relay Consumer shuts down, you have the opportunity to clean up any resources held by the consumer. For example, you could close any open files, network connections, or send a notification to your monitoring service.
Just implement a Teardown
method in your consumer and it will be called during the shutdown procedure.
using SignalWire.Relay;
using SignalWire.Relay.Calling;
using System;
using System.Collections.Generic;
namespace Example
{
internal class TeardownConsumer : Consumer
{
protected override void Setup()
{
Project = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
Token = "PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
Contexts = new List<string> { "test" };
}
protected override void Teardown()
{
// Clean up any resources when exiting.
}
protected override void OnIncomingCall(Call call)
{
AnswerResult resultAnswer = call.Answer();
call.PlayTTS("Welcome to SignalWire!");
call.Hangup();
}
}
internal class Program
{
// Standard entry point for any C# application
public static void Main()
{
// Create and run the consumer, this will block until the consumer is stopped
new TeardownConsumer().Run();
}
}
}
Running Consumers
Running a consumer is just like running any C# application, simply execute the program as a separate process and ensure you call Run()
on the Consumer. The process will stay up until you shut it down.
SignalWire.Relay.Client
SignalWire.Relay.Client
is the basic connection to Relay, allowing you send commands to Relay and set up handlers for inbound events.
Constructor
Constructs a client object to interact with Relay.
Parameters
project |
string | required | Project ID from your SignalWire Space |
token |
string | required | Token from your SignalWire Space |
Examples
Create a Client to interact with the Relay API.
Client client = new Client("my-project-id", "my-project-token");
Properties
Calling |
SignalWire.Relay.CallingAPI | Returns a SignalWire.Relay.CallingAPI instance associated with the client. |
Messaging |
SignalWire.Relay.MessagingAPI | Returns a SignalWire.Relay.MessagingAPI instance associated with the client. |
Methods
Connect
Activates the connection to the Relay API. The connection to Relay does not happen automatically so that you can setup handlers to events that might occur before the connection is successfully established.
Available In:
Returns
void
Examples
// Make sure you have attached the listeners you need before connecting the client, or you might miss some events.
client.Connect()
Disconnect
Disconnect the client from Relay.
Available In:
Returns
void
Examples
client.Disconnect()
Events
All available events you can attach a listener on.
OnReady |
The client has connected and may proceed with signalwire protocol setup. |
OnDisconnected |
The client has disconnected. |
SignalWire.Relay.CallingAPI
This represents the API interface for the Calling Relay Service. This object is used to make requests related to managing end to end calls.
Methods
DialPhone
Make an outbound PhoneCall and waits until it has been answered, times out, busy, or some other error occurs.
Available In:
Parameters
to |
string | required | The phone number of the party you are attempting to call. |
from |
string | required | The phone number the call is coming from. Must be a SignalWire number or SIP endpoint that you own. |
timeout |
int | optional | The time, in seconds, the call will ring before going to voicemail. Default: 30 |
Returns
SignalWire.Relay.Calling.DialResult
- The result object to interact with.
Examples
Make an outbound PhoneCall and obtain the Call object after it was answered.
DialResult resultDial = client.Calling.DialPhone("+1XXXXXXXXXX", "+1YYYYYYYYYY", timeout: 30);
if (resultDial.Successful)
{
// Call has been answered, it is available through resultDial.Call
}
NewPhoneCall
Create a new PhoneCall
object. The call has not started, but you can attach event listeners on it.
Available In:
Parameters
to |
string | required | The phone number of the party you are attempting to call. |
from |
string | required | The phone number the call is coming from. Must be a SignalWire number or SIP endpoint that you own. |
timeout |
int | optional | The time, in seconds, the call will ring before going to voicemail. Default: 30 |
Returns
SignalWire.Relay.Calling.PhoneCall
- A new call object.
Examples
Create a new PhoneCall object and Dial it.
PhoneCall call = client.Calling.NewPhoneCall("+1XXXXXXXXXX", "+1YYYYYYYYYY", timeout: 30);
call.OnEnded += (a, c, e, p) =>
{
// Call has been ended
};
DialResult resultDial = call.Dial();
if (resultDial.Successful)
{
call.Hangup();
}
SignalWire.Relay.Calling.AnswerResult
This object returned from Answer
method.
Properties
Successful |
bool | Indicates the action has completed successfully. |
Event |
SignalWire.Relay.Event |
The last event to complete the operation. |
SignalWire.Relay.Calling.Call
All calls in SignalWire have a common generic interface, Call
. A Call
is a connection between SignalWire and another device.
Properties
ID |
string | The unique identifier of the call. |
Type |
string | The type of call. Only phone is currently supported. |
State |
SignalWire.Relay.Calling.CallState |
The current state of the call. |
PreviousState |
SignalWire.Relay.Calling.CallState |
The previous state of the call. |
Context |
string | The context the call belongs to. |
Peer |
SignalWire.Relay.Calling.Call |
The call your original call is connected to. |
Active |
bool | Indicates the call is active. |
Ended |
bool | Indicates the call has ended. |
Answered |
bool | Indicates the call has been answered. |
Busy |
bool | Indicates the call ended with a busy signal. |
Methods
AMD
Alias for DetectAnsweringMachine
.
AMDAsync
Alias for DetectAnsweringMachineAsync
.
Answer
Answer an inbound call.
Available In:
Parameters
None
Returns
SignalWire.Relay.Calling.AnswerResult
- The result object to interact with.
Examples
Answer an inbound call and check if it was successful.
AnswerResult resultAnswer = call.Answer();
if (resultAnswer.Successful) {
// The call has been answered
}
Connect
Attempt to connect an existing call to a new outbound call and waits until one of the remote parties answers the call or the connect fails.
This method involves complex nested parameters.
You can connect to multiple devices in series, parallel, or any combination of both with creative use of the parameters. Series implies one device at a time, while parallel implies multiple devices at the same time.
Available In:
Parameters
devices |
List<List<SignalWire.Relay.Calling.CallDevice >> |
required | A nested list of devices. Outer list is dialed in series, while inner list is called in parallel to each other. |
ringback |
List<SignalWire.Relay.Calling.CallMedia > |
optional | A list of ringback media to be played while waiting for the call to be answered. |
Returns
SignalWire.Relay.Calling.ConnectResult
- The result object to interact with.
Examples
Trying to connect a call by calling in series +18991114444 and +18991114445.
ConnectResult resultConnect = call.Connect(new List<List<CallDevice>>
{
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114444",
FromNumber = "+1YYYYYYYYYY",
Timeout = 30,
}
}
},
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114445",
FromNumber = "+1YYYYYYYYYY",
Timeout = 20,
}
}
}
},
ringback: new List<CallMedia>
{
new CallMedia
{
Type = CallMedia.MediaType.ringtone,
Parameters = new CallMedia.RingtoneParams
{
Name = "us"
}
}
});
if (resultConnect.Successful) {
// The call was connected, and is available at resultConnect.Call
}
Combine serial and parallel calling. Call +18991114443 first and - if it doesn't answer - try calling in parallel +18991114444 and +18991114445. If none of the devices answer, continue the same process with +18991114446 and +18991114447.
ConnectResult resultConnect = call.Connect(new List<List<CallDevice>>
{
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114443",
FromNumber = "+1YYYYYYYYYY",
Timeout = 30,
}
}
},
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114444",
FromNumber = "+1YYYYYYYYYY",
Timeout = 30,
}
},
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114445",
FromNumber = "+1YYYYYYYYYY",
Timeout = 20,
}
}
},
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114446",
FromNumber = "+1YYYYYYYYYY",
Timeout = 30,
}
},
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114447",
FromNumber = "+1YYYYYYYYYY",
Timeout = 20,
}
}
}
});
if (resultConnect.Successful) {
// The call was connected, and is available at resultConnect.Call
}
ConnectAsync
Asynchronous version of Connect
. It does not wait the connect to complete or fail, but returns a ConnectAction
object you can interact with.
Available In:
Parameters
See Connect
for the parameter list.
Returns
SignalWire.Relay.Calling.ConnectAction
- The action object to interact with.
Examples
Trying to connect a call by calling in series +18991114444 and +18991114445.
ConnectAction actionConnect = call.ConnectAsync(new List<List<CallDevice>>
{
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114444",
FromNumber = "+1YYYYYYYYYY",
Timeout = 30,
}
}
},
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114445",
FromNumber = "+1YYYYYYYYYY",
Timeout = 20,
}
}
}
});
// Do other stuff while the call is being connected
if (actionConnect.Completed && actionConnect.Result.Successful) {
// The call was connected, and is available at actionConnect.Result.Call
}
Detect
Run a detector on the call and waits until the first detect update comes through. This is a general method for all types of detecting, see `DetectAnsweringMachine, DetectDigit
, or DetectFax
for more specific usage.
Available In:
Parameters
detect |
SignalWire.Relay.Calling.CallDetect |
required | The configuration for detection. |
Returns
SignalWire.Relay.Calling.DetectResult
- The result object to interact with.
Examples
Start a detector and if successful, checks whether the
Type
is human from theSignalWire.Relay.Calling.DetectResult
object.
DetectResult resultDetect = call.Detect(
new CallDetect
{
Type = CallDetect.DetectType.machine,
Parameters = new CallDetect.MachineParams
{
}
});
if (resultDetect.Successful)
{
if (resultDetect.Type == DetectResultType.Human)
{
// ...
}
}
DetectAsync
Asynchronous version of Detect
. It does not wait for the detection update but returns a SignalWire.Relay.Calling.DetectAction
object you can interact with. This is a general method for all types of detecting, see `DetectAnsweringMachine, DetectDigit
, or DetectFax
for more specific usage.
Available In:
Parameters
See Detect
for the parameter list.
Returns
SignalWire.Relay.Calling.DetectAction
- The action object to interact with.
Examples
Start a detector and stop it after 5 seconds.
DetectAction actionDetect = call.DetectAsync(
new CallDetect
{
Type = CallDetect.DetectType.machine,
Parameters = new CallDetect.MachineParams
{
}
});
Thread.Sleep(5000);
actionDetect.Stop();
DetectAnsweringMachine
This is a helper function that refines the use of Detect
. This simplifies detecting machines.
Available In:
Parameters
initialTimeout |
double | optional | The length of time in seconds to wait for the initial voice before giving up. Default to 4.5 . |
endSilenceTimeout |
double | optional | The length of time in seconds to wait for the voice to finish. Default to 1.0 . |
machineVoiceThreshold |
double | optional | The length of time in seconds for the voice to trigger a machine detection. Default to 1.25 . |
machineWordsThreshold |
int | optional | The quantity of words to trigger a machine detection. Default to 6 . |
waitForBeep |
bool? | optional | Indicates whether the detector should return immediately upon detecting a machine or if it should wait for the machine's beep to return. Default to false . |
Returns
SignalWire.Relay.Calling.DetectResult
- The result object to interact with.
Examples
Detect machine.
DetectResult resultDetect = call.DetectAnsweringMachine();
DetectAnsweringMachineAsync
Asynchronous version of DetectAnsweringMachine
. It does not wait for the first detection update, but returns a SignalWire.Relay.Calling.DetectAction
object you can interact with.
Available In:
Parameters
See DetectAnsweringMachine
for the parameter list.
Returns
SignalWire.Relay.Calling.DetectAction
- The action object to interact with.
Examples
Detect machine and stop after 5 seconds.
// within an asynchronous function ..
DetectAction actionDetect = call.DetectAnsweringMachineAsync();
Thread.Sleep(5000);
actionDetect.Stop();
DetectDigit
This is a helper function that refines the use of Detect
. This simplifies detecting DTMF.
Available In:
Parameters
digits |
string | optional | The digits to detect. Default to 0123456789*# . |
Returns
SignalWire.Relay.Calling.DetectResult
- The result object to interact with.
Examples
Detect DTMF digits.
DetectResult resultDetect = call.DetectDigit();
DetectDigitAsync
Asynchronous version of DetectDigit
. It does not wait for the first detection update, but returns a SignalWire.Relay.Calling.DetectAction
object you can interact with.
Available In:
Parameters
See DetectDigit
for the parameter list.
Returns
SignalWire.Relay.Calling.DetectAction
- The action object to interact with.
Examples
Detect DTMF digits and stop after 5 seconds.
// within an asynchronous function ..
DetectAction actionDetect = call.DetectDigitAsync();
Thread.Sleep(5000);
actionDetect.Stop();
DetectFax
This is a helper function that refines the use of Detect
. This simplifies detecting fax.
Available In:
Parameters
tone |
SignalWire.Relay.Calling.CallDetect.FaxParams.FaxTone ? |
optional | The tone to detect. Default to CED . |
Returns
SignalWire.Relay.Calling.DetectResult
- The result object to interact with.
Examples
Detect fax.
DetectResult resultDetect = call.DetectFax();
DetectFaxAsync
Asynchronous version of DetectFax
. It does not wait for the first detection update, but returns a SignalWire.Relay.Calling.DetectAction
object you can interact with.
Available In:
Parameters
See DetectFax
for the parameter list.
Returns
SignalWire.Relay.Calling.DetectAction
- The action object to interact with.
Examples
Detect fax and stop after 5 seconds.
// within an asynchronous function ..
DetectAction actionDetect = call.DetectFaxAsync();
Thread.Sleep(5000);
actionDetect.Stop();
DetectHuman
This is a helper function that refines the use of Detect
. This simplifies detecting humans.
Deprecated since: Use DetectAnsweringMachine
instead.
Parameters
initialTimeout |
double? | optional | The length of time in seconds to wait for the initial voice before giving up. Default to 4.5 . |
endSilenceTimeout |
double? | optional | The length of time in seconds to wait for the voice to finish. Default to 1.0 . |
machineVoiceThreshold |
double? | optional | The length of time in seconds for the voice to trigger a machine detection. Default to 1.25 . |
machineWordsThreshold |
int? | optional | The quantity of words to trigger a machine detection. Default to 6 . |
Returns
SignalWire.Relay.Calling.DetectResult
- The result object to interact with.
Examples
Detect human.
DetectResult resultDetect = call.DetectHuman();
DetectHumanAsync
Asynchronous version of DetectHuman
. It does not wait for the first detection update, but returns a SignalWire.Relay.Calling.DetectAction
object you can interact with.
Deprecated since: Use DetectAnsweringMachineAsync
instead.
Parameters
See DetectHuman
for the parameter list.
Returns
SignalWire.Relay.Calling.DetectAction
- The action object to interact with.
Examples
Detect human and stop after 5 seconds.
// within an asynchronous function ..
DetectAction actionDetect = call.DetectHumanAsync();
Thread.Sleep(5000);
actionDetect.Stop();
DetectMachine
This is a helper function that refines the use of Detect
. This simplifies detecting machines.
Deprecated since: Use DetectAnsweringMachine
instead.
Parameters
initialTimeout |
double | optional | The length of time in seconds to wait for the initial voice before giving up. Default to 4.5 . |
endSilenceTimeout |
double | optional | The length of time in seconds to wait for the voice to finish. Default to 1.0 . |
machineVoiceThreshold |
double | optional | The length of time in seconds for the voice to trigger a machine detection. Default to 1.25 . |
machineWordsThreshold |
int | optional | The quantity of words to trigger a machine detection. Default to 6 . |
Returns
SignalWire.Relay.Calling.DetectResult
- The result object to interact with.
Examples
Detect machine.
DetectResult resultDetect = call.DetectMachine();
DetectMachineAsync
Asynchronous version of DetectMachine
. It does not wait for the first detection update, but returns a SignalWire.Relay.Calling.DetectAction
object you can interact with.
Deprecated since: Use DetectAnsweringMachineAsync
instead.
Parameters
See DetectMachine
for the parameter list.
Returns
SignalWire.Relay.Calling.DetectAction
- The action object to interact with.
Examples
Detect machine and stop after 5 seconds.
// within an asynchronous function ..
DetectAction actionDetect = call.DetectMachineAsync();
Thread.Sleep(5000);
actionDetect.Stop();
Dial
This will start a call that was created with NewPhoneCall
(or another call creation method) and waits until the call has been answered or hung up.
Available In:
Parameters
None
Returns
SignalWire.Relay.Calling.DialResult
- The result object to interact with.
Examples
PhoneCall call = client.Calling.NewPhoneCall("+1XXXXXXXXXX", "+1YYYYYYYYYY");
DialResult resultDial = call.Dial();
if (resultDial.Successful) {
// Call has been answered
}
FaxReceive
Wait on a fax to come through the current call.
Available In:
Parameters
None
Returns
SignalWire.Relay.Calling.FaxResult
- The result object to interact with.
Examples
Start receiving a fax and check whether it was successful.
FaxResult resultFax = call.FaxReceive();
if (resultFax.Successful)
{
// ...
}
FaxSendAsync
Asynchronous version of FaxSend
. It does not wait for a fax but returns a SignalWire.Relay.Calling.FaxAction
object you can interact with.
Available In:
Parameters
See FaxSend
for the parameter list.
Returns
SignalWire.Relay.Calling.FaxAction
- The action object to interact with.
Examples
Start listening for a fax and stop it after 5 seconds.
FaxAction actionFax = call.FaxSendAsync();
Thread.Sleep(5000);
actionFax.Stop();
FaxSend
Wait on a fax to send to a destination.
Available In:
Parameters
document |
string | required | Location of the document to send. PDF format only. |
identity |
string | optional | Identity to display on receiving fax. Default is SignalWire DID . |
headerInfo |
string | optional | Custom info to add to header of each fax page. The info, along with identity, date, and page number will be included in the header. Set to empty string to disable sending any header. Default is SignalWire . |
Returns
SignalWire.Relay.Calling.FaxResult
- The result object to interact with.
Examples
Send a fax and check whether it was successful.
FaxResult resultFax = call.FaxSend("https://cdn.signalwire.com/fax/dummy.pdf");
if (resultFax.Successful)
{
// ...
}
FaxSendAsync
Asynchronous version of FaxSend
. It does not wait for a fax but returns a SignalWire.Relay.Calling.FaxAction
object you can interact with.
Available In:
Parameters
See FaxSend
for the parameter list.
Returns
SignalWire.Relay.Calling.FaxAction
- The action object to interact with.
Examples
Start sending a fax and stop it after 5 seconds.
FaxAction actionFax = call.FaxSendAsync("https://cdn.signalwire.com/fax/dummy.pdf");
Thread.Sleep(5000);
actionFax.Stop();
Hangup
Hangup the call.
Available In:
Parameters
SignalWire.Relay.Calling.DisconnectReason
- The reason for the disconnect, defaulted to hangup
.
Returns
SignalWire.Relay.Calling.HangupResult
- The result object to interact with.
Examples
Hangup a call and check if it was successful.
HangupResult resultHangup = call.Hangup();
if (resultHangup.Successful) {
// Call has been disconnected with the default hangup reason
}
Play
Play one or more media to a Call and wait until the playing has ended. This is a general method for all types of playing, see PlayAudio
, PlaySilence
, PlayTTS
, or PlayRingtone
for more specific usage.
Available In:
Parameters
media |
List<SignalWire.Relay.Calling.CallMedia > |
required | One or more objects describing media to be played in order. |
volume |
double? | optional | Controls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0 . |
Returns
SignalWire.Relay.Calling.PlayResult
- The result object to interact with.
Examples
Play multiple media elements in the call.
PlayResult resultPlay = call.Play(
new List<CallMedia>
{
new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "Listen to this awesome file!"
}
},
new CallMedia
{
Type = CallMedia.MediaType.audio,
Parameters = new CallMedia.AudioParams
{
URL = "https://cdn.signalwire.com/default-music/welcome.mp3"
}
},
new CallMedia
{
Type = CallMedia.MediaType.silence,
Parameters = new CallMedia.SilenceParams
{
Duration = 5
}
},
new CallMedia
{
Type = CallMedia.MediaType.ringtone,
Parameters = new CallMedia.RingtoneParams
{
Name = "us"
}
},
new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "Did you like it?"
}
}
},
volume: 4.0
);
PlayAsync
Asynchronous version of Play
. It does not wait for theplaying to complete, but returns a [
SignalWire.Relay.Calling.PlayAction`](#api-reference-signalwire-relay-calling-playaction) object you can interact with.
Available In:
Parameters
See Play
for the parameter list.
Returns
SignalWire.Relay.Calling.PlayAction
- The action object to interact with.
Examples
Play multiple media elements in the call and stop them after 5 seconds.
PlayAction actionPlay = call.PlayAsync(
new List<CallMedia>
{
new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "Listen to this awesome file!"
}
},
new CallMedia
{
Type = CallMedia.MediaType.audio,
Parameters = new CallMedia.AudioParams
{
URL = "https://cdn.signalwire.com/default-music/welcome.mp3"
}
},
new CallMedia
{
Type = CallMedia.MediaType.silence,
Parameters = new CallMedia.SilenceParams
{
Duration = 5
}
},
new CallMedia
{
Type = CallMedia.MediaType.ringtone,
Parameters = new CallMedia.RingtoneParams
{
Name = "us"
}
},
new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "Did you like it?"
}
}
},
volume: 4.0
);
Thread.Sleep(5000);
actionPlay.Stop();
PlayAudio
This is a helper function that refines the use of Play
. This simplifies playing an audio file.
Available In:
Parameters
url |
string | required | Http(s) URL to audio resource to play. |
volume |
double? | optional | Controls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0 . |
Returns
SignalWire.Relay.Calling.PlayResult
- The result object to interact with.
Examples
Play an MP3 file.
PlayResult resultPlay = call.PlayAudio("https://cdn.signalwire.com/default-music/welcome.mp3", volume: 4.0);
PlayAudioAsync
Asynchronous version of PlayAudio
. It does not wait for the playing to complete, but returns a SignalWire.Relay.Calling.PlayAction
object you can interact with.
Available In:
Parameters
See PlayAudio
for the parameter list.
Returns
SignalWire.Relay.Calling.PlayAction
- The action object to interact with.
Examples
Play an MP3 file and stop it after 5 seconds.
// within an asynchronous function ..
PlayAction actionPlay = call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3", volume: 4.0);
Thread.Sleep(5000);
actionPlay.Stop();
PlayRingtone
This is a helper function that refines the use of Play
. This simplifies playing ringtones.
Available In:
Parameters
name |
string | required | The name of the ringtone, see SignalWire.Relay.Calling.CallMedia.RingtoneParams . |
duration |
double? | optional | Default to null , 1 ringtone iteration. |
volume |
double? | optional | Controls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0 . |
Returns
SignalWire.Relay.Calling.PlayResult
- The result object to interact with.
Examples
Play a single US ringtone.
PlayResult resultPlay = call.PlayRingtone("us");
PlayRingtoneAsync
Asynchronous version of PlayRingtone
. It does not wait for the playing to complete, but returns a SignalWire.Relay.Calling.PlayAction
object you can interact with.
Available In:
Parameters
See PlayRingtone
for the parameter list.
Returns
SignalWire.Relay.Calling.PlayAction
- The action object to interact with.
Examples
Play US ringtone for 60 seconds, if Agent is available, stop the play.
PlayAction actionPlay = call.PlayRingtoneAsync("us", duration: 60);
if (agent.Available()) {
actionPlay.Stop();
}
PlaySilence
This is a helper function that refines the use of Play
. This simplifies playing silence.
Available In:
Parameters
duration |
double | required | Seconds of silence to play. |
Returns
SignalWire.Relay.Calling.PlayResult
- The result object to interact with.
Examples
Play silence for 10 seconds.
PlayResult resultPlay = call.PlaySilence(10);
PlaySilenceAsync
Asynchronous version of PlaySilence
. It does not wait for the playing to complete, but returns a SignalWire.Relay.Calling.PlayAction
object you can interact with.
Available In:
Parameters
See PlaySilence
for the parameter list.
Returns
SignalWire.Relay.Calling.PlayAction
- The action object to interact with.
Examples
Play silence for 60 seconds, if Agent is available, stop the play.
PlayAction actionPlay = call.PlaySilenceAsync(60);
if (agent.Available()) {
actionPlay.Stop();
}
PlayTTS
This is a helper function that refines the use of Play
. This simplifies playing TTS.
Available In:
Parameters
text |
string | required | The text to speak. |
gender |
string | optional | male or female . Default to female . |
language |
string | optional | Default to en-US . |
volume |
double? | optional | Controls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0 . |
Returns
SignalWire.Relay.Calling.PlayResult
- The result object to interact with.
Examples
Play TTS.
PlayResult resultPlay = call.PlayTTS("Welcome to SignalWire!", gender: "male", volume: 4.0 });
PlayTTSAsync
Asynchronous version of PlayTTS
. It does not wait for the playing to complete, but returns a SignalWire.Relay.Calling.PlayAction
object you can interact with.
Available In:
Parameters
See PlayTTS
for the parameter list.
Returns
SignalWire.Relay.Calling.PlayAction
- The action object to interact with.
Examples
Play TTS and stop it after 3 seconds.
PlayAction actionPlay = call.PlayTTSAsync("Welcome to SignalWire! Making communications easy for everyone!", gender: "male", volume: 4.0 })
Thread.Sleep(3000);
actionPlay.Stop();
Prompt
Play one or more media while collecting user's input from the call at the same time, such as digits
and speech
.
It waits until the collection succeed or timeout is reached. This is a general method for all types of playing, see PromptAudio
or PromptTTS
for more specific usage.
Available In:
Parameters
media |
List<SignalWire.Relay.Calling.CallMedia > |
required | One or more objects describing media to be played in order. |
collect |
SignalWire.Relay.Calling.CallCollect |
required | The configuration for input collection. |
volume |
double? | optional | Controls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0 . |
Returns
SignalWire.Relay.Calling.PromptResult
- The result object to interact with.
Examples
Ask user to enter their PIN and collect the digits.
PromptResult resultPrompt = call.Prompt(
new List<CallMedia>
{
new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "Welcome to SignalWire! Please enter your PIN",
}
}
},
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
volume: 4.0);
if (resultPrompt.Successful)
{
// The collected input is in resultPrompt.Result
}
PromptAsync
Asynchronous version of Prompt
. It does not wait for the collect to complete, but returns a SignalWire.Relay.Calling.PromptAction
object you can interact with.
Available In:
Parameters
See Prompt
for the parameter list.
Returns
SignalWire.Relay.Calling.PromptAction
- The action object to interact with.
Examples
Ask user to enter their PIN and collect the digits.
PromptAction actionPrompt = call.PromptAsync(
new List<CallMedia>
{
new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "Welcome to SignalWire! Please enter your PIN",
}
},
new CallMedia
{
Type = CallMedia.MediaType.audio,
Parameters = new CallMedia.AudioParams
{
URL = "https://cdn.signalwire.com/default-music/welcome.mp3",
}
}
},
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
volume: 4.0);
// Do other stuff
if (actionPrompt.Completed)
{
if (actionPrompt.Result.Successful)
{
// The collected input is in actionPrompt.Result.Result
}
}
PromptAudio
This is a helper function that refines the use of Prompt
.
This function simplifies playing an audio file while collecting user input from the call, such as digits
and speech
.
Available In:
Parameters
url |
string | required | Http(s) URL to audio resource to play. |
collect |
SignalWire.Relay.Calling.CallCollect |
required | The configuration for input collection. |
volume |
double? | optional | Controls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0 . |
Returns
SignalWire.Relay.Calling.PromptResult
- The result object to interact with.
Examples
Collect user digits while playing an MP3 file.
PromptResult resultPrompt = call.PromptAudio(
"https://cdn.signalwire.com/default-music/welcome.mp3",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
volume: 4.0);
if (resultPrompt.Successful)
{
// The collected input is in resultPrompt.Result
}
PromptAudioAsync
Asynchronous version of PromptAudio
. It does not wait for the collection to complete, but returns a SignalWire.Relay.Calling.PromptAction
object you can interact with.
Available In:
Parameters
See PromptAudio
for the parameter list.
Returns
SignalWire.Relay.Calling.PromptAction
- The action object to interact with.
Examples
Collect user digits while playing an MP3 file.
PromptAction actionPrompt = call.PromptAudioAsync(
"https://cdn.signalwire.com/default-music/welcome.mp3",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
volume: 4.0);
if (actionPrompt.Completed)
{
if (actionPrompt.Result.Successful)
{
// The collected input is in actionPrompt.Result.Result
}
}
PromptRingtone
This is a helper function that refines the use of Prompt
.
This function simplifies playing ringtones while collecting user input from the call, such as digits
and speech
.
Available In:
Parameters
name |
string | required | The name of the ringtone, see SignalWire.Relay.Calling.CallMedia.RingtoneParams . |
collect |
SignalWire.Relay.Calling.CallCollect |
required | The configuration for input collection. |
duration |
double? | optional | Default to null , 1 ringtone iteration. |
volume |
double? | optional | Controls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0 . |
Returns
SignalWire.Relay.Calling.PromptResult
- The result object to interact with.
Examples
Play a US ringtone once and collect digits.
PromptResult resultPrompt = call.PromptRingtone(
"us",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
volume: 4.0);
if (resultPrompt.Successful)
{
// The collected input is in resultPrompt.Result
}
PromptRingtoneAsync
Asynchronous version of PromptRingtone
. It does not wait for the collection to complete, but returns a SignalWire.Relay.Calling.PromptAction
object you can interact with.
Available In:
Parameters
See PromptRingtone
for the parameter list.
Returns
SignalWire.Relay.Calling.PromptAction
- The action object to interact with.
Examples
Play a US ringtone once and collect digits.
PromptAction actionPrompt = call.PromptRingtoneAsync(
"us",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
volume: 4.0);
if (actionPrompt.Completed)
{
if (actionPrompt.Result.Successful)
{
// The collected input is in actionPrompt.Result.Result
}
}
PromptTTS
This is a helper function that refines the use of Prompt
.
This function simplifies playing TTS while collecting user input from the call, such as digits
and speech
.
Available In:
Parameters
text |
string | required | The text to speak. |
collect |
SignalWire.Relay.Calling.CallCollect |
required | The configuration for input collection. |
gender |
string | optional | male or female . Default to female . |
language |
string | optional | Default to en-US . |
volume |
double? | optional | Controls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0 . |
Returns
SignalWire.Relay.Calling.PromptResult
- The result object to interact with.
Examples
Ask user to enter their PIN and collect the digits.
PromptResult resultPrompt = call.PromptTTS(
"Welcome to SignalWire! Please enter your PIN",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
gender: "male",
volume: 4.0);
if (resultPrompt.Successful)
{
// The collected input is in resultPrompt.Result
}
PromptTTSAsync
Asynchronous version of PromptTTS
. It does not wait for the collection to complete, but returns a SignalWire.Relay.Calling.PromptAction
object you can interact with.
Available In:
Parameters
See PromptTTS
for the parameter list.
Returns
SignalWire.Relay.Calling.PromptAction
- The action object to interact with.
Examples
Ask user to enter their PIN and collect the digits.
PromptAction actionPrompt = call.PromptTTSAsync(
"Welcome to SignalWire! Please enter your PIN",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
gender: "male",
volume: 4.0);
if (actionPrompt.Completed)
{
if (actionPrompt.Result.Successful)
{
// The collected input is in actionPrompt.Result.Result
}
}
Record
Start recording the call and waits until the recording ends or fails.
Available In:
Parameters
record |
SignalWire.Relay.Calling.CallRecord |
required | The configuration for recording. |
Returns
SignalWire.Relay.Calling.RecordResult
- The result object to interact with.
Examples
Start recording audio in the call for both direction in stereo mode, if successful, grab
Url
,Duration
andSize
from theSignalWire.Relay.Calling.RecordResult
object.
RecordResult resultRecord = call.Record(
new CallRecord
{
Audio = new CallRecord.AudioParams
{
Stereo = true,
Direction = CallRecord.AudioParams.AudioDirection.both,
}
});
if (resultRecord.Successful)
{
// The URL for the recording is available in resultRecord.Url
}
RecordAsync
Asynchronous version of Record
. It does not wait for the end of the recording
but returns a SignalWire.Relay.Calling.RecordAction
object you can interact with.
Available In:
Parameters
See Record
for the parameter list.
Returns
SignalWire.Relay.Calling.RecordAction
- The action object to interact with.
Examples
Start recording audio in the call for both direction in stereo mode and stop it after 5 seconds.
RecordAction actionRecord = call.RecordAsync(
new CallRecord
{
Audio = new CallRecord.AudioParams
{
Stereo = true,
Direction = CallRecord.AudioParams.AudioDirection.both,
}
});
Thread.Sleep(5000);
actionRecord.Stop();
SendDigits
Sends DTMF digits to the other party on the call.
Available In:
Parameters
digits |
string | required | The digits to send. Allowed digits are 1234567890*#ABCD . w and W may be used to indicate short and long waits respectively. If any invalid characters are present, the entire operation is rejected. |
Returns
SignalWire.Relay.Calling.SendDigitsResult
- The result object to interact with.
Examples
Send digits and check whether sending was successful.
SendDigitsResult result = call.SendDigits("123w456W789");
if (result.Successful)
{
// ...
}
SendDigitsAsync
Asynchronous version of SendDigits
. It does not wait for all digits to be sent but returns a SignalWire.Relay.Calling.SendDigitsAction
object you can interact with.
Available In:
Parameters
See SendDigits
for the parameter list.
Returns
SignalWire.Relay.Calling.SendDigitsAction
- The action object to interact with.
Examples
Start sending digits.
SendDigitsAction action = call.SendDigits("123w456W789");
// Do other things
Tap
Start tapping the call and waits until the tap ends or fails.
Available In:
Parameters
tap |
SignalWire.Relay.Calling.CallTap |
required | The configuration for tapping. |
device |
SignalWire.Relay.Calling.CallTapDevice |
required | The configuration for the target device. |
Returns
SignalWire.Relay.Calling.TapResult
- The result object to interact with.
Examples
Start tapping audio in the call for both directions.
TapResult resultTap = call.Tap(
new CallTap
{
Audio = new CallTap.AudioParams
{
Direction = CallTap.AudioParams.AudioDirection.both,
}
},
new CallTapDevice
{
Type = CallTapDevice.DeviceType.rtp,
Parameters = new CallTapDevice.RTPParams
{
Address = "1.2.3.4",
Port = 12345,
}
});
if (resultTap.Successful)
{
// The RTP data is flowing to the device
}
TapAsync
Asynchronous version of Tap
. It does not wait for the end of the tapping but returns a TapAction
object you can interact with.
Available In:
Parameters
See Tap
for the parameter list.
Returns
SignalWire.Relay.Calling.TapAction
- The action object to interact with.
Examples
Start tapping audio in the call for both directions and stop it after 5 seconds.
TapAction actionTap = call.TapAsync(
new CallTap
{
Audio = new CallTap.AudioParams
{
Direction = CallTap.AudioParams.AudioDirection.both,
}
},
new CallTapDevice
{
Type = CallTapDevice.DeviceType.rtp,
Parameters = new CallTapDevice.RTPParams
{
Address = "1.2.3.4",
Port = 12345,
}
});
Thread.Sleep(5000);
actionTap.Stop();
WaitFor
Block until the current state of the call is one of the specified SignalWire.Relay.Calling.CallState
values. This is a general method, see WaitForAnswered
, WaitForEnded
, WaitForEnding
, or WaitForRinging
for more specific usage.
Available In:
Parameters
timeout |
TimeSpan? | required | The maximum amount of time to wait. null is interpreted as an infinite wait. |
states |
params SignalWire.Relay.Calling.CallState |
required | The states to wait for. |
Returns
bool
- Will have the value true
if the state is consistent with one of the provided states or false
if a timeout occurred.
Examples
Wait to see if a call is answered
bool stateValid = call.WaitFor(null, CallState.answered);
if (stateValid) {
// The call is answered
}
WaitForAnswered
This is a helper function that refines the use of WaitFor
. Block until the current state of the call is the answered SignalWire.Relay.Calling.CallState
.
Available In:
Parameters
timeout |
TimeSpan? | optional | The maximum amount of time to wait. null is interpreted as an infinite wait. Default to null . |
Returns
bool
- Will have the value true
if the state is consistent with the specified SignalWire.Relay.Calling.CallState
or false
if a timeout occurred.
Examples
Wait to see if a call is answered
bool stateValid = call.WaitForAnswered();
if (stateValid) {
// The call is answered
}
WaitForEnded
This is a helper function that refines the use of WaitFor
. Block until the current state of the call is the ended SignalWire.Relay.Calling.CallState
.
Available In:
Parameters
timeout |
TimeSpan? | optional | The maximum amount of time to wait. null is interpreted as an infinite wait. Default to null . |
Returns
bool
- Will have the value true
if the state is consistent with the specified SignalWire.Relay.Calling.CallState
or false
if a timeout occurred.
Examples
Wait to see if a call is ended
bool stateValid = call.WaitForEnded();
if (stateValid) {
// The call is ended
}
WaitForEnding
This is a helper function that refines the use of WaitFor
. Block until the current state of the call is the ending SignalWire.Relay.Calling.CallState
.
Available In:
Parameters
timeout |
TimeSpan? | optional | The maximum amount of time to wait. null is interpreted as an infinite wait. Default to null . |
Returns
bool
- Will have the value true
if the state is consistent with the specified SignalWire.Relay.Calling.CallState
or false
if a timeout occurred.
Examples
Wait to see if a call is ending
bool stateValid = call.WaitForEnding();
if (stateValid) {
// The call is ending
}
WaitForRinging
This is a helper function that refines the use of WaitFor
. Block until the current state of the call is the ringing SignalWire.Relay.Calling.CallState
.
Available In:
Parameters
timeout |
TimeSpan? | optional | The maximum amount of time to wait. null is interpreted as an infinite wait. Default to null . |
Returns
bool
- Will have the value true
if the state is consistent with the specified SignalWire.Relay.Calling.CallState
or false
if a timeout occurred.
Examples
Wait to see if a call is ringing
bool stateValid = call.WaitForRinging();
if (stateValid) {
// The call is ringing
}
Events
All these events can be used to track the calls lifecycle and instruct SignalWire on what to do for each different state.
State Events
To track the state of a call.
OnStateChange |
The call is changing state, generalized event for the following events. |
OnRinging |
The call is ringing and has not yet been answered. |
OnAnswered |
The call has been picked up. |
OnEnding |
The call is hanging up. |
OnEnded |
The call has ended. |
Connect Events
To track the connect state of a call.
OnConnectStateChange |
The connect state is changing, generalized event for the following events. |
OnConnectFailed |
The last call connection attempt failed. |
OnConnectConnecting |
Currently calling the phone number(s) to connect. |
OnConnectConnected |
The calls are being connected together. |
OnConnectDisconnected |
The call was either never connected or the last call connection completed. |
Detect Events
To track a detection.
OnDetectError |
The detection failed. |
OnDetectFinished |
The detection has finished. |
OnDetectUpdate |
The detection state is changing, generalized event for the following events. |
Fax Events
To track a fax operation.
OnFaxError |
The fax operation failed. |
OnFaxFinished |
The fax operation finished. |
OnFaxPage |
The fax operation sent a page. |
Play Events
To track a playback state.
OnPlayStateChange |
The play state is changing, generalized event for the following events. |
OnPlayPlaying |
One of the medias are being played to the call. |
OnPlayError |
The play of media failed. |
OnPlayFinished |
The playing of media has finished. |
Prompt Events
To track a prompt state.
OnPrompt |
The prompt action on the call has ended. |
Record Events
To track a recording state.
OnRecordStateChange |
The record state is changing, generalized event for the following events. |
OnRecordRecording |
The call is being recorded. |
OnRecordFinished |
The recording has finished. |
OnRecordNoInput |
The recording failed due to no input detected. |
Send Digits Events
To receive a message when the digits are finished sending.
OnSendDigitsStateChange |
The send digits state is changing, generalized event for the following events. |
OnSendDigitsFinished |
The digits have finished sending. |
Tap Events
To track an active tap.
OnTapStateChange |
The tap state is changing, generalized event for the following events. |
OnTapTapping |
The call is being tapped. |
OnTapFinished |
The tapping has finished. |
SignalWire.Relay.Calling.CallCollect
This object represents call input that is being collected, multiple things may be collected at the same time such as digits and speech.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallCollect collect = new CallCollect
{
Digits = new CallCollect.DigitsParams
{
Max = 1
}
};
Properties
InitialTimeout |
double? | This is the initial timeout in seconds if no input is received. Default: 5 seconds |
Digits |
SignalWire.Relay.Calling.CallCollect.DigitsParams |
This object contains configuration for collecting digits. |
Speech |
SignalWire.Relay.Calling.CallCollect.SpeechParams |
This object contains configuration for collecting speech. |
Methods
None
Events
None
SignalWire.Relay.Calling.CallCollect.DigitsParams
This object represents the parameters specific to digits collecting.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallCollect collect = new CallCollect
{
Digits = new CallCollect.DigitsParams
{
Max = 1
}
};
Properties
Max |
int | The maximum number of digits to collect, must be greater than zero. |
Terminators |
string | A string of individual characters that can be used to terminate prematurely. |
DigitTimeout |
double? | The timeout before terminating prematurely if at least one digit was collected. Default: 1 second |
Methods
None
Events
None
SignalWire.Relay.Calling.CallCollect.SpeechParams
This object represents the parameters specific to speech collecting.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallCollect collect = new CallCollect
{
Speech = new CallCollect.SpeechParams
{
// No required parameters
}
};
Properties
SpeechTimeout |
double? | The max duration before terminating if long speech was detected. Default: 5 seconds |
EndSilenceTimeout |
double? | The timeout before terminating prematurely if speech was detected and then stops. Default: 1 second |
Methods
None
Events
None
SignalWire.Relay.Calling.CallCollectType
This is an enumeration that represents the different possible types of input collection that can occur.
Values
error |
An error occurred during input collection. |
no_input |
The collection failed because no input was detected. |
no_match |
The collection failed because no match was detected. |
digit |
The collection succeeded with digit input. |
speech |
The collection succeeded with speech input. |
SignalWire.Relay.Calling.CallConnectState
This is an enumeration that represents the different possible states a connect operation may have.
Values
failed |
The connect has failed. |
connecting |
One or more peer calls are connecting. |
connected |
The peer call has been connected. |
disconnected |
The peer call has been disconnected. |
SignalWire.Relay.Calling.CallDetect
This object represents a call detection.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallDetect detect = new CallDetect
{
Type = CallDetect.DetectType.machine,
Parameters = new CallDetect.MachineParams
{
// Use default machine detection parameters
}
};
Properties
Type |
SignalWire.Relay.Calling.CallDetect.DetectType |
This object indicates the type of the configuration object. |
Parameters |
object | The configuration object for the operation. |
Methods
ParametersAs<T>()
This is a helper method to convert the Parameters
to the real type.
Available In:
Parameters
T |
Type | required | This is the data type for the conversion, see SignalWire.Relay.Calling.CallDetect.DetectType for more information. |
Returns
T
- This is an instance of the data type resulting from the conversion, see SignalWire.Relay.Calling.CallDetect.DetectType
for more information.
Examples
CallDetect.DigitParams digitParams = detect.ParametersAs<CallDetect.DigitParams>();
CallDetect.FaxParams faxParams = detect.ParametersAs<CallDetect.FaxParams>();
CallDetect.MachineParams machineParams = detect.ParametersAs<CallDetect.MachineParams>();
Events
None
SignalWire.Relay.Calling.CallDetect.DetectType
This is an enumeration that represents the possible detection types.
Values
digit |
The detect parameters are SignalWire.Relay.Calling.CallDetect.DigitParams . |
fax |
The detect parameters are SignalWire.Relay.Calling.CallDetect.FaxParams . |
machine |
The detect parameters are SignalWire.Relay.Calling.CallDetect.MachineParams . |
SignalWire.Relay.Calling.CallDetect.DigitParams
This object represents the parameters specific to digit detection.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallDetect detect = new CallDetect
{
Type = CallDetect.DetectType.digit,
Parameters = new CallDetect.DigitParams
{
// No required parameters
}
};
Properties
Digits |
string | The digits to detect. Default: 0123456789*# |
Methods
None
Events
None
SignalWire.Relay.Calling.CallDetect.FaxParams
This object represents the parameters specific to fax detection.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallDetect detect = new CallDetect
{
Type = CallDetect.DetectType.fax,
Parameters = new CallDetect.FaxParams
{
// No required parameters
}
};
Properties
Tone |
SignalWire.Relay.Calling.CallDetect.FaxParams.FaxTone |
The tone to detect. Default: CED |
Methods
None
Events
None
SignalWire.Relay.Calling.CallDetect.FaxParams.FaxTone
This is an enumeration that represents the possible fax tones.
Values
CED |
The CED tone. |
CNG |
The CNG tone. |
SignalWire.Relay.Calling.CallDetect.MachineParams
This object represents the parameters specific to machine detection.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallDetect detect = new CallDetect
{
Type = CallDetect.DetectType.machine,
Parameters = new CallDetect.MachineParams
{
// No required parameters
}
};
Properties
EndSilenceTimeout |
double? | The length of time in seconds to wait for the voice to finish. Default: 1.0 |
InitialTimeout |
double? | The length of time in seconds to wait for the initial voice before giving up. Default: 4.5 |
MachineVoiceThreshold |
double? | The length of time in seconds for the voice to trigger a machine detection. Default: 1.25 |
MachineWordsThreshold |
int? | The quantity of words to trigger a machine detection. Default: 6 |
Methods
None
Events
None
SignalWire.Relay.Calling.CallDevice
This object represents a call device.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallDevice device = new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+1XXXXXXXXXX",
FromNumber = "+1YYYYYYYYYY",
}
};
Properties
Type |
SignalWire.Relay.Calling.CallDevice.DeviceType |
This object indicates the type of the configuration object. |
Parameters |
object | The configuration object for the device. |
Methods
ParametersAs<T>()
This is a helper method to convert the Parameters
to the real type.
Available In:
Parameters
T |
Type | required | This is the data type for the conversion, see SignalWire.Relay.Calling.CallDevice.DeviceType for more information. |
Returns
T
- This is an instance of the data type resulting from the conversion, see SignalWire.Relay.Calling.CallDevice.DeviceType
for more information.
Examples
CallDevice.PhoneParams phoneParams = device.ParametersAs<CallDevice.PhoneParams>();
Events
None
SignalWire.Relay.Calling.CallDevice.DeviceType
This is an enumeration that represents the possible device types.
Values
phone |
The device parameters are SignalWire.Relay.Calling.CallDevice.PhoneParams . |
SignalWire.Relay.Calling.CallDevice.PhoneParams
This object represents the parameters specific to a phone device.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallDevice device = new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+1XXXXXXXXXX",
FromNumber = "+1YYYYYYYYYY",
}
};
Properties
FromNumber |
string | The source phone number in E164 format. |
ToNumber |
string | The destination phone number in E164 format. |
Timeout |
string | The maximum time in seconds to wait for a call to begin. |
Methods
None
Events
None
SignalWire.Relay.Calling.CallMedia
This object represents a call media that is being played.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallMedia media = new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "I'm a little teapot"
}
};
Properties
Type |
SignalWire.Relay.Calling.CallMedia.MediaType |
This is the type of the media. |
Parameters |
object | This is the object that represents the parameters specific to the type, see SignalWire.Relay.Calling.CallMedia.MediaType for more information. |
Methods
ParametersAs<T>()
This is a helper method to convert the Parameters
to the real type.
Available In:
Parameters
T |
Type | required | This is the data type for the conversion, see SignalWire.Relay.Calling.CallMedia.MediaType for more information. |
Returns
T
- This is an instance of the data type resulting from the conversion, see SignalWire.Relay.Calling.CallMedia.MediaType
for more information.
Examples
CallMedia.AudioParams audioParams = media.ParametersAs<CallMedia.AudioParams>();
CallMedia.TTSParams ttsParams = media.ParametersAs<CallMedia.TTSParams>();
CallMedia.SilenceParams silenceParams = media.ParametersAs<CallMedia.SilenceParams>();
CallMedia.RingtoneParams ringtoneParams = media.ParametersAs<CallMedia.RingtoneParams>();
Events
None
SignalWire.Relay.Calling.CallMedia.AudioParams
This object represents the parameters specific to audio media.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallMedia media = new CallMedia
{
Type = CallMedia.MediaType.audio,
Parameters = new CallMedia.AudioParams
{
URL = "http://example.somewhere.com/test.wav"
}
};
Properties
URL |
string | The URL of the audio file to play. |
Methods
None
Events
None
SignalWire.Relay.Calling.CallMedia.MediaType
This is an enumeration that represents the possible types of media.
Values
audio |
The media parameters are SignalWire.Relay.Calling.CallMedia.AudioParams . |
tts |
The media parameters are SignalWire.Relay.Calling.CallMedia.TTSParams . |
silence |
The media parameters are SignalWire.Relay.Calling.CallMedia.SilenceParams . |
ringtone |
The media parameters are SignalWire.Relay.Calling.CallMedia.RingtoneParams . |
SignalWire.Relay.Calling.CallMedia.RingtoneParams
This object represents the parameters specific to ringtone media.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallMedia media = new CallMedia
{
Type = CallMedia.MediaType.ringtone,
Parameters = new CallMedia.RingtoneParams
{
Name = "us",
Duration = 5.0
}
};
Properties
Name |
string | The name of the ringtone to play, based on short country codes. Values: at au bg br be ch cl cn cz de dk ee es fi fr gr hu il in it lt jp mx my nl no nz ph pl pt ru se sg th uk us tw ve za |
Duration |
double? | How long to play the ringtone in seconds. Default: null, which plays one full ring iteration |
Methods
None
Events
None
SignalWire.Relay.Calling.CallMedia.SilenceParams
This object represents the parameters specific to silence media.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallMedia media = new CallMedia
{
Type = CallMedia.MediaType.silence,
Parameters = new CallMedia.SilenceParams
{
Duration = 1.0
}
};
Properties
Duration |
double | The duration in seconds the silence is played. |
Methods
None
Events
None
SignalWire.Relay.Calling.CallMedia.TTSParams
This object represents the parameters specific to tts media.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallMedia media = new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "I'm a little teapot"
}
};
Properties
Text |
string | The text to process into speech. |
Methods
None
Events
None
SignalWire.Relay.Calling.CallPlayState
This is an enumeration that represents the different possible states a play operation may have.
Values
playing |
The media is being played. |
error |
An error has occurred. |
finished |
The media is finished playing. |
SignalWire.Relay.Calling.CallRingback
This object represents a call ringback that is being played.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallRingback ringbackAudio = new CallRingback
{
Type = CallRingback.RingbackType.audio,
Parameters = new CallRingback.AudioParams
{
URL = "http://path/to/audio/file"
}
};
CallRingback ringbackRingtone = new CallRingback
{
Type = CallRingback.RingbackType.ringtone,
Parameters = new CallRingback.RingtoneParams
{
Name = "us",
Duration = 30
}
};
CallRingback ringbackSilence = new CallRingback
{
Type = CallRingback.RingbackType.silence,
Parameters = new CallRingback.SilenceParams
{
Duration = 30
}
};
CallRingback ringbackTTS = new CallRingback
{
Type = CallRingback.RingbackType.tts,
Parameters = new CallRingback.TTSParams
{
Gender = "female",
Language = "en",
Text = "I'm a little teapot"
}
};
Properties
Type |
SignalWire.Relay.Calling.CallRingback.RingbackType |
This is the type of the media. |
Parameters |
object | This is the object that represents the parameters specific to the type, see SignalWire.Relay.Calling.CallRingback.RingbackType for more information. |
Methods
ParametersAs<T>()
This is a helper method to convert the Parameters
to the real type.
Available In:
Parameters
T |
Type | required | This is the data type for the conversion, see SignalWire.Relay.Calling.CallRingback.RingbackType for more information. |
Returns
T
- This is an instance of the data type resulting from the conversion, see SignalWire.Relay.Calling.CallRingback.RingbackType
for more information.
Examples
CallRingback.AudioParams audioParams = ringbackAudio.ParametersAs<CallRingback.AudioParams>();
CallRingback.RingtoneParams ringtoneParams = ringbackRingtone.ParametersAs<CallRingback.RingtoneParams>
CallRingback.SilenceParams silenceParams = ringbackSilence.ParametersAs<CallRingback.SilenceParams>();
CallRingback.TTSParams ttsParams = ringbackTTS.ParametersAs<CallRingback.TTSParams>();
Events
None
SignalWire.Relay.Calling.CallRingback.AudioParams
This object represents the parameters specific to audio ringback.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallRingback ringback = new CallRingback
{
Type = CallRingback.RingbackType.audio,
Parameters = new CallRingback.AudioParams
{
URL = "https://path/to/audio/file"
}
};
Properties
URL |
string | The URL of the audio file to play. |
Methods
None
Events
None
SignalWire.Relay.Calling.CallRingback.RingbackType
This is an enumeration that represents the possible types of call ringbacks.
Values
audio |
The audio ringback parameters are SignalWire.Relay.Calling.CallRingback.AudioParams . |
ringtone |
The ringtone ringback parameters are SignalWire.Relay.Calling.CallRingback.RingtoneParams . |
tts |
The tts ringback parameters are SignalWire.Relay.Calling.CallRingback.TTSParams . |
silence |
The silence ringback parameters are SignalWire.Relay.Calling.CallRingback.SilenceParams . |
SignalWire.Relay.Calling.CallRingback.RingtoneParams
This object represents the parameters specific to ringtone ringback.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallRingback ringback = new CallRingback
{
Type = CallRingback.RingbackType.ringtone,
Parameters = new CallRingback.RingtoneParams
{
Name = "us",
Duration = 30
}
};
Properties
Name |
string | The country code for desired ringtone. |
Duration |
integer | The max duration in seconds for the ringtone. |
Methods
None
Events
None
SignalWire.Relay.Calling.CallRingback.SilenceParams
This object represents the parameters specific to silence ringback.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallRingback ringback = new CallRingback
{
Type = CallRingback.RingbackType.audio,
Parameters = new CallRingback.SilenceParams
{
Duration = 30
}
};
Properties
Duration |
string | The maximum duration for silence on ringback. |
Methods
None
Events
None
SignalWire.Relay.Calling.CallRingback.TtsParams
This object represents the parameters specific to tts ringback.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallRingback ringback = new CallRingback
{
Type = CallRingback.RingbackType.tts,
Parameters = new CallRingback.TTSParams
{
Gender = "female",
Language = "en",
Text = "I'm a little teapot"
}
};
Properties
Gender |
string | The gender of the tts engine. |
Language |
string | The language/dialect of the tts engine. |
Text |
string | The verbiage to synthesize with tts engine. |
Methods
None
Events
None
SignalWire.Relay.Calling.CallRecord
This object represents call recording that is being handled, multiple things may be recorded in the same recording in the future, but currently only audio is available. It is also possible to start multiple different recordings at the same time.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallRecord record = new CallRecord
{
Audio = new CallRecord.AudioParams
{
// Use default audio recording parameters
}
};
Properties
Audio |
SignalWire.Relay.Calling.CallRecord.AudioParams |
This object contains configuration for recording audio. |
Methods
None
Events
None
SignalWire.Relay.Calling.CallRecordState
This is an enumeration that represents the different possible states a record operation may have.
Values
recording |
The call is being recorded. |
finished |
The recording has finished. |
no_input |
The recording failed due to no input detected. |
SignalWire.Relay.Calling.CallRecord.AudioParams
This object represents the parameters specific to audio recording.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallRecord record = new CallRecord
{
Audio = new CallRecord.AudioParams
{
// Use default audio recording parameters
}
};
Properties
Beep |
bool? | Whether or not to include a beep at the start of the recording. Default: false |
Format |
SignalWire.Relay.Calling.CallRecord.AudioParams.AudioFormat ? |
The format of the audio recording. Default: mp3 |
Stereo |
bool? | Whether to include stereo or only mono tracks in the audio recording. Default: false |
Direction |
SignalWire.Relay.Calling.CallRecord.AudioParams.AudioDirection ? |
The direction to include in the audio recording, speak (what the caller says), listen (what the caller hears), or both. Default: speak |
InitialTimeout |
double? | How long to wait in seconds until audio is detected to begin recording. Default: 5 seconds Note: Disable with 0 |
EndSilenceTimeout |
double? | How long to wait in seconds after audio is no longer detected to terminate recording. Default: 1 second Note: Disable with 0 |
Terminators |
string | A string of individual DTMF characters that can be used to terminate recording. Default: #* |
Methods
None
Events
None
SignalWire.Relay.Calling.CallRecord.AudioParams.AudioDirection
This is an enumeration that represents the possible directions for audio recordings.
Values
listen |
The recording includes what is heard by the owner. |
speak |
The recording includes what is said by the owner. |
both |
The recording includes what is heard and said by the owner. |
SignalWire.Relay.Calling.CallRecord.AudioParams.AudioFormat
This is an enumeration that represents the possible formats for audio recordings.
Values
mp3 |
The recording is mp3 format. |
wav |
The recording is wav format. |
SignalWire.Relay.Calling.CallSendDigitsState
This is an enumeration that represents the different possible states any call may have for a send digits operation.
Values
finished |
The digits have been sent. |
SignalWire.Relay.Calling.CallState
This is an enumeration that represents the different possible call states any call may have.
Values
created |
The call has been created. |
ringing |
The call is ringing. |
answered |
The call has been answered. |
ending |
The call is ending. |
ended |
The call has ended. |
SignalWire.Relay.Calling.CallTap
This object represents a call tap that is being handled. Currently only audio tapping is available.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallTap tap = new CallTap
{
Type = CallTap.TapType.audio,
Parameters = new CallTap.AudioParams
{
// Use default audio tapping parameters
}
};
Properties
Type |
SignalWire.Relay.Calling.CallTap.TapType |
This object indicates the type of the configuration object. |
Parameters |
object | The configuration object for the operation. |
Methods
ParametersAs<T>()
This is a helper method to convert the Parameters
to the real type.
Available In:
Parameters
T |
Type | required | This is the data type for the conversion, see SignalWire.Relay.Calling.CallTap.TapType for more information. |
Returns
T
- This is an instance of the data type resulting from the conversion, see SignalWire.Relay.Calling.CallTap.TapType
for more information.
Examples
CallTap.AudioParams audioParams = tap.ParametersAs<CallTap.AudioParams>();
Events
None
SignalWire.Relay.Calling.CallTap.AudioParams
This object represents the parameters specific to audio tapping.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallTap tap = new CallTap
{
Audio = new CallTap.AudioParams
{
// Use default audio tapping parameters
}
};
Properties
Direction |
SignalWire.Relay.Calling.CallTap.AudioParams.AudioDirection |
The direction to include in the audio tapping, speak (what the caller says), listen (what the caller hears), or both. Default: speak |
Methods
None
Events
None
SignalWire.Relay.Calling.CallTap.AudioParams.AudioDirection
This is an enumeration that represents the possible directions for audio tapping.
Values
listen |
The tap includes what is heard by the owner. |
speak |
The tap includes what is said by the owner. |
both |
The tap includes what is heard and said by the owner. |
SignalWire.Relay.Calling.CallTap.TapType
This is an enumeration that represents the possible tap types.
Values
audio |
The tap parameters are SignalWire.Relay.Calling.CallTap.AudioParams . |
SignalWire.Relay.Calling.CallTapState
This is an enumeration that represents the different possible states a tap operation may have.
Values
tapping |
The tap is active. |
finished |
The tap is finished. |
SignalWire.Relay.Calling.CallTapDevice
This object represents call tap device, this may represent a source or destination.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallTapDevice device = new CallTapDevice
{
Type = CallTapDevice.DeviceType.rtp,
Parameters = new CallTapDevice.RTPParams
{
Address = "1.2.3.4",
Port = 12345,
}
};
Properties
Type |
SignalWire.Relay.Calling.CallTapDevice.DeviceType |
This is the type of the device. |
Parameters |
object | This is the object that represents the parameters specific to the type, see SignalWire.Relay.Calling.CallTapDevice.DeviceType for more information. |
Methods
ParametersAs<T>()
This is a helper method to convert the Parameters
to the real type.
Available In:
Parameters
T |
Type | required | This is the data type for the conversion, see SignalWire.Relay.Calling.CallMedia.MediaType for more information. |
Returns
T
- This is an instance of the data type resulting from the conversion, see SignalWire.Relay.Calling.CallMedia.MediaType
for more information.
Examples
CallTapDevice.RTPParams rtpParams = device.ParametersAs<CallTapDevice.RTPParams>();
Events
None
SignalWire.Relay.Calling.CallTapDevice.DeviceType
This is an enumeration that represents the possible types of tap devices.
Values
rtp |
The media parameters are SignalWire.Relay.Calling.CallTapDevice.RTPParams . |
SignalWire.Relay.Calling.CallTapDevice.RTPParams
This object represents the parameters specific to RTP device tapping.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
CallTapDevice device = new CallTapDevice
{
Type = CallTapDevice.DeviceType.rtp,
Parameters = new CallTapDevice.RTPParams
{
Address = "1.2.3.4",
Port = 12345,
}
};
Properties
Address |
string | The IP address of the tap device. |
Port |
integer | The port of the tap device. |
Methods
None
Events
None
SignalWire.Relay.Calling.ConnectAction
This object returned from ConnectAsync
method that represents a connect operation that is currently active on a call.
Properties
Result |
SignalWire.Relay.Calling.ConnectResult |
Final result of connecting. |
State |
SignalWire.Relay.Calling.CallConnectState |
Current state of the connect operation. |
Completed |
bool | Whether the connection attempt has completed. |
Payload |
List<List<SignalWire.Relay.Calling.CallDevice >> |
Payload sent to Relay to start the connect. |
SignalWire.Relay.Calling.ConnectResult
This object returned from Connect
method that represents the final result of a connection between your call and another peer.
Properties
Successful |
bool | Whether the recording has completed successfully. |
Event |
SignalWire.Relay.Event |
The last event that completed the call. |
Call |
SignalWire.Relay.Calling.Call |
Peer Call connected with yours when successful. |
SignalWire.Relay.Calling.DetectAction
This object returned from DetectAsync
method that represents a detection operation that is currently active on a call.
Properties
ControlID |
string | The identifier used to control the operation. |
Result |
SignalWire.Relay.Calling.DetectResult |
Final result of detection. |
Completed |
bool | Whether the detect operation has completed. |
Payload |
SignalWire.Relay.Calling.CallDetect |
Payload sent to Detect to start the detect operation. |
Methods
Stop
Stop the action immediately.
Available In:
Parameters
None
Returns
SignalWire.Relay.Calling.StopResult
- The result object to interact with.
Examples
Start a detector and stop it after 5 seconds.
DetectAction actionDetect = call.DetectAsync(
new CallDetect
{
Type = CallDetect.DetectType.machine,
Parameters = new CallDetect.MachineParams
{
}
});
Thread.Sleep(5000);
StopResult resultStop = actionDetect.Stop();
SignalWire.Relay.Calling.DetectResult
This object returned from Detect
method or part of the action when DetectAsync
completes, which represents the final result of a detection operation.
Properties
Successful |
bool | Whether the detect operation has completed successfully. |
Event |
SignalWire.Relay.Event |
The last event that completed the call. |
Result |
string | Detail related to the event. |
Type |
SignalWire.Relay.Calling.DetectResultType |
The type of the detection. |
SignalWire.Relay.Calling.DetectResultType
This is an enumeration that represents the possible types of detection.
Values
DTMF |
A digit detection. |
Error |
The detection came back with an error. |
Fax |
A fax detection. |
Finished |
The detection is finished. |
Human |
A human detection. |
Machine |
A machine detection. |
Unknown |
The detection type could not be determined. |
SignalWire.Relay.Calling.DisconnectReason
This is an enumeration that represents the possible types of disconnect reasons.
Values
hangup |
Normal hangup. |
cancel |
Canceled. |
busy |
Busy signal. |
noAnswer |
Was not answered. |
decline |
Declined. |
error |
Error occurred. |
SignalWire.Relay.Calling.DialResult
This object returned from Dial
method.
Properties
Successful |
bool | Whether the call has been answered successfully. |
Event |
SignalWire.Relay.Event |
The last event that completed the call. |
Call |
SignalWire.Relay.Calling.Call |
Reference to the call. |
SignalWire.Relay.Calling.Direction
This is an enumeration that represents the possible direction types.
Values
send |
The operation is an outbound operation. |
receive |
The operation is an inbound operation. |
SignalWire.Relay.Calling.FaxAction
This object returned from FaxReceiveAsync
and FaxSendAsync
methods that represents a fax operation that is currently active on a call.
Properties
ControlID |
string | The identifier used to control the operation. |
Result |
SignalWire.Relay.Calling.FaxResult |
Final result of the fax operation. |
Completed |
bool | Whether the fax operation has completed. |
Payload |
SignalWire.Relay.Calling.SendFaxPayload |
Payload sent to FaxSend to perform a fax operation. This field will be null for receive fax operations. |
Methods
Stop
Stop the action immediately.
Available In:
Parameters
None
Returns
SignalWire.Relay.Calling.StopResult
- The result object to interact with.
Examples
Start listening for faxes and stop it after 5 seconds.
FaxAction actionFax = call.FaxReceiveAsync();
Thread.Sleep(5000);
StopResult resultStop = actionFax.Stop();
SignalWire.Relay.Calling.FaxResult
This object returned from FaxReceive
and FaxSend
methods or part of the action when FaxReceiveAsync
and FaxSendAsync
complete, which represents the final result of a fax operation.
Properties
Event |
SignalWire.Relay.Event |
The last event that completed the call. |
Direction |
SignalWire.Relay.Calling.Direction |
Indicates the direction of the result. |
Document |
string | The location of the faxed document. |
Identity |
string | The phone number representing the client side of the operation. |
Pages |
int | The quantity of successfully transmitted pages. |
RemoteIdentity |
string | The phone number representing the remote side of the operation. |
Successful |
bool | Whether the fax operation has completed successfully. |
SignalWire.Relay.Calling.HangupResult
This object returned from Hangup
method.
Properties
Successful |
bool | Whether the call has been hung up successfully. |
Event |
SignalWire.Relay.Event |
The last event that completed the call. |
Reason |
SignalWire.Relay.Calling.DisconnectReason |
The hangup reason. |
SignalWire.Relay.Calling.PhoneCall
This object represents an active PSTN phone call, and inherits from SignalWire.Relay.Calling.Call
.
Constructor
The constructors for this object are internal and available only to the library. There are no public details provided for the constructors as they are only used internally.
Parameters
Not Available
Examples
Not Available
Properties
To |
string | The to number in E164 format. |
From |
string | The from number in E164 format. |
Timeout |
int | Timeout in seconds before the call fails after it is started. |
See SignalWire.Relay.Calling.Call
for additional inherited properties.
Methods
None
See SignalWire.Relay.Calling.Call
for additional inherited methods.
Events
None
See SignalWire.Relay.Calling.Call
for additional inherited events.
SignalWire.Relay.Calling.PlayAction
This object returned from one of the asynchronous Play
methods that represent a play operation that is currently active on a call.
Properties
ControlID |
string | The identifier used for controlling the operation. |
Result |
SignalWire.Relay.Calling.PlayResult |
Final result of playing. |
State |
SignalWire.Relay.Calling.CallPlayState |
Current state of the play operation. |
Completed |
bool | Whether the play operation has completed. |
Payload |
List<SignalWire.Relay.Calling.CallMedia > |
Payload sent to Relay to start playing. |
Methods
Stop
Stop the action immediately.
Available In:
Parameters
None
Returns
SignalWire.Relay.Calling.StopResult
- The result object to interact with.
Examples
Start playing an audio file and stop it after 5 seconds.
PlayAction actionPlay = call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3");
Thread.Sleep(5000);
StopResult resultStop = actionPlay.Stop();
Volume
Change the volume of the action immediately.
Available In:
Parameters
volume |
double | The volume from -40dB to +40dB where 0 is unchanged. |
Returns
SignalWire.Relay.Calling.PlayVolumeResult
- The result object to interact with.
Examples
Start playing an audio file and change the volume after after 5 seconds.
PlayAction actionPlay = call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3");
Thread.Sleep(5000);
actionPlay.Volume(4.0);
Pause
Pause playback of the action immediately.
Available In:
Parameters
None
Returns
SignalWire.Relay.Calling.PlayPauseResult
- The result object to interact with.
Examples
Start playing an audio file and pause it after 5 seconds.
PlayAction actionPlay = call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3");
Thread.Sleep(5000);
actionPlay.Pause();
Resume
Resume playback of the action immediately.
Available In:
Parameters
None
Returns
SignalWire.Relay.Calling.PlayResumeResult
- The result object to interact with.
Examples
Start playing an audio file and pause it after 5 seconds, then resume it after 5 seconds.
PlayAction actionPlay = call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3");
Thread.Sleep(5000);
actionPlay.Pause();
Thread.Sleep(5000);
actionPlay.Resume();
SignalWire.Relay.Calling.PlayResult
This object returned from one the synchronous Play
methods or part of the action when an asynchronous equivalent completes, which represent the final result of a play operation.
Properties
Successful |
bool | Whether the play operation has completed successfully. |
Event |
SignalWire.Relay.Event |
The last event that completed the call. |
SignalWire.Relay.Calling.PlayPauseResult
This object returned from the synchronous Pause
method, which represent the final result of a play pause operation.
Properties
Successful |
bool | Whether the play pause operation has completed successfully. |
Event |
SignalWire.Relay.Event |
The last event that completed the call. |
SignalWire.Relay.Calling.PlayResumeResult
This object returned from the synchronous Resume
method, which represent the final result of a play resume operation.
Properties
Successful |
bool | Whether the play resume operation has completed successfully. |
Event |
SignalWire.Relay.Event |
The last event that completed the call. |
SignalWire.Relay.Calling.PlayVolumeResult
This object returned from the synchronous Volume
method, which represent the final result of a play volume operation.
Properties
Successful |
bool | Whether the play volume operation has completed successfully. |
SignalWire.Relay.Calling.PromptAction
This object returned from one of asynchronous Prompt
methods that represent a prompt operation that is currently active on a call.
Properties
ControlID |
string | The identifier used to control the operation. |
Result |
SignalWire.Relay.Calling.PromptResult |
Final result of this prompt. |
State |
SignalWire.Relay.Calling.CallPlayState |
Current state of the play operation. |
Completed |
bool | Whether the prompt operation has completed. |
PlayPayload |
List<SignalWire.Relay.Calling.CallMedia > |
Payload sent to Relay to start playing. |
CollectPayload |
SignalWire.Relay.Calling.CallCollect |
Payload sent to Relay to collect input. |
Methods
Stop
Stop the action immediately.
Available In:
Parameters
None
Returns
SignalWire.Relay.Calling.StopResult
- The result object to interact with.
Examples
Ask user to enter a PIN and stop the action after 5 seconds.
PromptAction actionPrompt = call.PromptTTSAsync(
"Welcome to SignalWire! Please enter your PIN",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
});
Thread.Sleep(5000);
StopResult resultStop = actionPrompt.Stop();
Volume
Change the volume of the action immediately.
Available In:
Parameters
volume |
double | The volume from -40dB to +40dB where 0 is unchanged. |
Returns
SignalWire.Relay.Calling.PromptVolumeResult
- The result object to interact with.
Examples
Ask user to enter a PIN and change the volume after 1 second.
PromptAction actionPrompt = call.PromptTTSAsync(
"Welcome to SignalWire! Please enter your PIN",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
});
Thread.Sleep(1000);
actionPrompt.Volume(4.0);
SignalWire.Relay.Calling.PromptResult
This object returned from one the synchronous Prompt
methods or part of the action when an asynchronous equivalent completes, which represent the final result of a prompt operation.
Properties
Successful |
bool | Whether the play operation has completed successfully. |
Event |
SignalWire.Relay.Event |
The last event that completed the call. |
Type |
SignalWire.Relay.Calling.CallCollectType |
The type of the collected result. |
Result |
string | Result of prompt operation. |
Terminator |
string | User input that terminated a digit prompt. |
Confidence |
double? | Confidence of the result on a speech prompt. |
SignalWire.Relay.Calling.PromptVolumeResult
This object returned from the synchronous Volume
method, which represent the final result of a prompt volume operation.
Properties
Successful |
bool | Whether the prompt volume operation has completed successfully. |
SignalWire.Relay.Calling.RecordAction
This object returned from RecordAsync
method that represents a record operation that is currently active on a call.
Properties
ControlID |
string | The identifier used to control the operation. |
Result |
SignalWire.Relay.Calling.RecordResult |
Final result of recording. |
State |
SignalWire.Relay.Calling.CallRecordState |
Current state of the record operation. |
Completed |
bool | Whether the record operation has completed. |
Payload |
SignalWire.Relay.Calling.CallRecord |
Payload sent to Relay to start the record operation. |
Url |
string | Url of the recording provided by Relay, the file may not be present at the URL until the recording is finished. |
Methods
Stop
Stop the action immediately.
Available In:
Parameters
None
Returns
SignalWire.Relay.Calling.StopResult
- The result object to interact with.
Examples
Start recording in stereo mode and stop it if
agent
is not available in 3 seconds.
RecordAction actionRecord = call.RecordAsync(
new CallRecord
{
Audio = CallRecord.AudioParams
{
Stereo = true,
}
});
Thread.Sleep(3000);
if (!agent.IsAvailable)
{
StopResult resultStop = actionRecord.Stop();
}
SignalWire.Relay.Calling.RecordResult
This object returned from Record
method or part of the action when RecordAsync
completes, which represents the final result of a record operation.
Properties
Successful |
bool | Whether the record operation has completed successfully. |
Event |
SignalWire.Relay.Event |
The last event that completed the call. |
Url |
string | Url to the recorded file. |
Duration |
double? | Duration of the recording in seconds. |
Size |
long? | Size of the recording in bytes. |
SignalWire.Relay.Calling.SendDigitsAction
This object returned from SendDigitsAsync
method that represents a send digits operation that is currently active on a call.
Properties
ControlID |
string | The identifier used to control the operation. |
Completed |
bool | Whether the operation has completed. |
Payload |
string | Payload sent to SendDigitsAsync to perform a send digits operation. |
Result |
SignalWire.Relay.Calling.SendDigitsResult |
Final result of the send digits operation. |
State |
SignalWire.Relay.Calling.CallSendDigitsState |
The state of the operation. |
SignalWire.Relay.Calling.SendDigitsResult
This object returned from SendDigits
method, which represents the result of a send digits operation.
Properties
Event |
SignalWire.Relay.Event |
The last event that completed the call. |
Successful |
bool | Whether the send operation has successfully sent the digits. |
SignalWire.Relay.Calling.SendFaxPayload
This object is returned from FaxAction
.
Properties
Document |
string | The location of the fax document. |
Identity |
string | Identity to display on receiving fax. |
HeaderInfo |
string | Custom info to add to header of each fax page. The info, along with identity, date, and page number will be included in the header. |
SignalWire.Relay.Calling.StopResult
This object is returned from one the synchronous Stop methods on an action when an asynchronous operation is being stopped, which represent the final result of a stop operation.
Properties
Successful |
bool | Whether the stop operation has completed successfully. |
SignalWire.Relay.Calling.TapAction
This object returned from TapAsync
method that represents a tap operation that is currently active on a call.
Properties
ControlID |
string | The identifier used to control the operation. |
Result |
SignalWire.Relay.Calling.TapResult |
Final result of tapping. |
State |
SignalWire.Relay.Calling.CallTapState |
Current state of the tap operation. |
Completed |
bool | Whether the tap operation has completed. |
Payload |
SignalWire.Relay.Calling.CallTap |
Payload sent to Relay to start the tap operation. |
SourceDevice |
SignalWire.Relay.Calling.CallTapDevice |
The source device of the tap operation. |
Methods
Stop
Stop the action immediately.
Available In:
Parameters
None
Returns
SignalWire.Relay.Calling.StopResult
- The result object to interact with.
Examples
Start tapping and stop it if
agent
is not available in 3 seconds.
TapAction actionTap = call.TapAsync(
new CallTap
{
Audio = new CallTap.AudioParams
{
Direction = CallTap.AudioParams.AudioDirection.both,
}
},
new CallTapDevice
{
Type = CallTapDevice.DeviceType.rtp,
Parameters = new CallTapDevice.RTPParams
{
Address = "1.2.3.4",
Port = 12345,
}
});
Thread.Sleep(3000);
if (!agent.IsAvailable)
{
StopResult resultStop = actionTap.Stop();
}
SignalWire.Relay.Calling.TapResult
This object returned from Tap
method or part of the action when TapAsync
completes, which represents the final result of a tap operation.
Properties
Successful |
bool | Whether the tap operation has completed successfully. |
Event |
SignalWire.Relay.Event |
The last event that completed the call. |
Tap |
SignalWire.Relay.Calling.CallTap |
The call tap configuration. |
SourceDevice |
SignalWire.Relay.Calling.CallTapDevice |
The source tap device details. |
DestinationDevice |
SignalWire.Relay.Calling.CallTapDevice |
The destination tap device details. |
SignalWire.Relay.Event
This object represents the last Relay event that completed an operation on the Call.
Properties
Name |
string | The event name. |
Payload |
JObject | Raw JSON object of the Relay event. |
SignalWire.Relay.MessagingAPI
This represents the API interface for the Messaging Relay Service. This object is used to make requests related to managing SMS and MMS messages.
Methods
Send
Send an outbound SMS or MMS message.
Available In:
Parameters
context |
string | required | The context to receive inbound events. |
to |
string | required | The phone number to send to. |
from |
string | required | The phone number to place the message from. Must be a SignalWire phone number or short code that you own. |
source |
SignalWire.Relay.Messaging.SendSource |
required | The message. May be populated by a body string or a list of media URLs. |
tags |
List<string> | optional | Tags to tag the message with for searching in the UI. Default: Empty |
Returns
SignalWire.Relay.Messaging.SendResult
- The result object to interact with.
Examples
Send a message.
SendResult resultSend = client.Messaging.Send(validContext, "+1XXXXXXXXXX", "+1YYYYYYYYYY");
if (resultSend.Successful)
{
// Message has been queued, you can subscribe to MessagingAPI.OnMessageStateChange to receive further updates
}
Events
All these events can be used to track the message lifecycle and instruct SignalWire on what to do for each different state.
State Events
To track the state of a sent message.
OnMessageStateChange |
The message is changing state, generalized event for the following events. |
OnMessageDelivered |
The message has been delivered. Due to the nature of SMS and MMS, receiving a delivered event is not guaranteed, even if the message is delivered successfully. |
OnMessageFailed |
The message delivery failed. |
OnMessageInitiated |
The message delivery has been started. |
OnMessageQueued |
The message has been put into the queue for delivery. |
OnMessageSent |
The message has been sent for delivery. |
OnMessageUndelivered |
The message has not been delivered. Due to the nature of SMS and MMS, receiving an undelivered event is not guaranteed, even if the message fails to be delivered. |
Receive Events
OnMessageReceived |
A message has been received. |
SignalWire.Relay.Messaging.Message
A Message
represents an SMS and/or MMS message.
Properties
Body |
string | The SMS message body. May be null but at least one of Body and Media will be populated. |
Context |
string | The context the message belongs to. |
Direction |
SignalWire.Relay.Messaging.Direction |
The direction of the message. |
From |
string | The number that sent the message in E164 format. |
ID |
string | The unique identifier of the message. |
Media |
List<string> | The list of URLs associated with the MMS. May be null but at least one of Body and Media will be populated. |
Tags |
List<string> | The list of tags associated to the message. May be null . |
To |
string | The number that received the message in E164 format. |
Reason |
string | For messages that are undelivered or failed , a string explaining the message's state. null otherwise. |
Segments |
int | The number of segments in the message. |
State |
SignalWire.Relay.Messaging.MessageState |
The current state of the message. |
SignalWire.Relay.Messaging.SendResult
This object returned from Send
method, which represents the result of a send operation.
Properties
MessageID |
string | The ID of the message. |
Successful |
bool | Whether the send operation has successfully queued the message. |
SignalWire.Relay.Messaging.SendSource
This object is used as an argument to Send
.
Constructors
From Body
body |
string | The body of the message. |
From Media
media |
List<string> | A list of URLs to use for the message. |
From Body/Media
body |
string | The body of the message. |
media |
List<string> | A list of URLs to use for the message. |
Properties
Body |
string | The body of the message. |
Media |
List<string> | A list of URLs to use for the message. |
SignalWire.Relay.RelayTask
A SignalWire.Relay.RelayTask
is a simple way to send jobs to your SignalWire.Relay.Consumer
from a short lived process, like a web framework. Relay Tasks allow you to pass commands down to your Consumers without blocking your short lived request. Think of a Relay Task as a way to queue a job for your background workers to processes asynchronously.
For example, if you wanted to make an outbound call and play a message when your user clicks a button on your web application, since Relay is a realtime protocol and relies on you to tell it what to do in realtime, if you did this within your web application, your web server would block until the call was finished... this may take a long time! Instead, simply create a new Relay Task. This task will be handled by a running Relay Consumer process and your web application can respond back to your user immediately.
Constructor
The only constructor is the default constructor, properties should all be assigned by initializer or after construction.
Parameters
None
Examples
Basic Example
RelayTask task = new RelayTask
{
SpaceID = validSpaceID,
ProjectID = validProjectID,
Context = validContext,
Message = new JObject {
["greet"] = "Hello"
},
}
Properties
SpaceID |
string | The SignalWire space ID. |
ProjectID |
string | The SignalWire project ID. |
Timestamp |
double | Seconds since the epoch with up to microsecond resolution (hence double). Represents the time the task was received. |
Context |
string | The context used to receive events. |
Message |
JObject | The message to send. |
Methods
Deliver
Deliver a message to the specified host. This is typically not used directly, TaskingAPI.Deliver
is used instead.
Available In:
Parameters
host |
string | required | The host to post the message to. |
project |
string | required | The SignalWire project ID. |
token |
string | required | The authentication token. |
context |
string | required | The context to receive inbound events. |
message |
JObject | required | The message to send. |
Returns
void
Examples
Send a message.
RelayTask.Deliver(validHost, validProjectID, validToken, validContext, new JObject {
["number_to_call"] = "+1555XXXXXXX",
["message_to_play"] = "We have a message for you",
});
Events
None
SignalWire.Relay.TaskingAPI
This represents the API interface for the Tasking Relay Service. A SignalWire.Relay.RelayTask
is simple way to send jobs to your SignalWire.Relay.Consumer
from a short lived process, like a web framework. Relay Tasks allow you to pass commands down to your Consumers without blocking your short lived request. Think of a Relay Task as a way to queue a job for your background workers to processes asynchronously.
For example, if you wanted to make an outbound call and play a message when your user clicks a button on your web application, since Relay is a realtime protocol and relies on you to tell it what to do in realtime, if you did this within your web application, your web server would block until the call was finished... this may take a long time! Instead, simply create a new Relay Task. This task will be handled by a running Relay Consumer process and your web application can respond back to your user immediately.
Methods
Deliver
Deliver the specified message.
Available In:
Parameters
context |
string | required | The context to receive inbound events. |
message |
JObject | required | The message to deliver. |
Returns
bool
- true
if the delivery is successfully started, false
if a problem is encountered.
Examples
Send a message.
bool isSuccessful = client.Tasking.Deliver(
validContext,
new JObject() {
["number_to_call"] = "+1555XXXXXXX",
["message_to_play"] = "We have a message for you",
});
if (isSuccessful)
{
// Message has been queued, you can subscribe to TaskingAPI.OnTaskReceived to receive further updates
}
Events
All these events can be used to track a task.
Receive Events
OnTaskReceived |
A task has been received. |
Examples
Follow the examples to see how's easy to use the Relay SDK to interact with inbound or outbound calls.
Inbound Calls
Using SignalWire.Relay.Consumer to manage inbound calls from both
home
andoffice
contexts. Answer the call, ask the user to enter their PIN and playback the digits sent if successful.
using SignalWire.Relay;
using SignalWire.Relay.Calling;
using System;
using System.Collections.Generic;
namespace Example
{
internal class ExampleConsumer : Consumer
{
protected override void Setup()
{
Project = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
Token = "PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
Contexts = new List<string> { "home", "office" };
}
// This is executed in a new thread each time, so it is safe to use blocking calls
protected override void OnIncomingCall(Call call)
{
// Answer the incoming call, block until it's answered or an error occurs
AnswerResult resultAnswer = call.Answer();
// Prompt with TTS and collect the PIN, block until it's finished or an error occurs
PromptResult resultPrompt = call.PromptTTS(
"Welcome to SignalWire! Please enter your PIN",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams { Max = 4, DigitTimeout = 5 }
});
if (resultPrompt.Successful)
{
// Play back what was collected
call.PlayTTS("You entered " + resultPrompt.Result + ". Thanks and good bye!");
}
// Hangup
call.Hangup();
}
}
internal class Program
{
public static void Main()
{
new ExampleConsumer().Run();
}
}
}
Outbound Calls
Make a call and, on
answered
, prompt the user to enter digits.
using SignalWire.Relay;
using SignalWire.Relay.Calling;
using System;
namespace Example
{
internal class ExampleConsumer : Consumer
{
protected override void Setup()
{
Project = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
Token = "PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
}
protected override void Ready()
{
// Create a new phone call and dial it immediately, block until it's answered, times out,
// busy, or another error occurs
DialResult resultDial = Client.Calling.DialPhone("+1XXXXXXXXXX", "+1YYYYYYYYYY");
// Prompt with TTS and collect the PIN, block until it's finished or an error occurs
PromptResult resultPrompt = resultDial.Call.PromptTTS(
"Welcome to SignalWire! Please enter your PIN",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams { Max = 4, DigitTimeout = 5 }
});
if (resultPrompt.Successful)
{
// Play back what was collected
resultDial.Call.PlayTTS("You entered " + resultPrompt.Result + ". Thanks and good bye!");
}
// Hangup
resultDial.Call.Hangup();
}
}
internal class Program
{
public static void Main()
{
new ExampleConsumer().Run();
}
}
}