Create a ICallCommand

General

Starting at version 2.22.126 of antony, you are able to provide a command within antonys' call window. To build meaningfull commands here, you can access the data of the call itselve.

Tl;Dr;

Example

As an example we want to show an action, who simply create a Ticket with some data from the call. Therefore we need to register it within antonys DI Container. Remember, that the registry needs to be registered (see Tl;Dr;)

public class ExampleAntonyRegistry { [AntonyServiceRegistry()] public void Register(IServiceCollection services) { services.AddTransient<ICallCommand, ExampleCallAction>(); } }

Of course we need to implement the command to. Here is the example.

In the first Lines (5-9) we declare the AntonyCommandInfo by the recommended AntonyCommandInfoBuilder. Be sure to place WithGroupName and WithPageName (or WithGeneralPageName). Otherwise you might get exceptions. The CommandStateChanged and GetCommandState is also implemented.

This class implement the IModuleSelector<CallCommandSelector> directly and provides the action only, if the call is incoming. The Execution will create a simple http-call by accessing some data of the call.

public class ExampleCallAction : ICallCommand, IModuleSelector<CallCommandSelector> { public IModuleSelector<CallCommandSelector> Selector => this; public AntonyCommandInfo ActionInfo => new AntonyCommandInfoBuilder() .WithDisplayName("-> Ticket") .WithGroupName("Example") .WithGeneralPageName() .Build(); public event EventHandler CommandStateChanged; public async Task ExecuteAsync(ICall call, IntPtr parentWindow, IProgressReporter reporter) { using (var client = new HttpClient()) { var content = new StringContent($"{{" + $"\"from\": {call.FromNumber}," + $"\"title\": From antony call," + $"\"description\": {call.Subject}," + $"}}"); await client.PostAsync("http://example.ticketsystem.com/api/tickets", content); } } public CommandState GetCommandState() { return CommandState.Normal; } public AntonyPriority GetPriority(CallCommandSelector selectorParameter) { if (selectorParameter.Direction == CallDirection.Incoming) return AntonyPriority.Buildin; return AntonyPriority.None; } }

The code above should provide an example howto implement a ICallCommand. Of course this is not production ready, as we dont have authentication, configuration or Exception handling!

You are able to access all client side services here. For example the IUserInfoService or IClientAppointmentService to create an appointment.

Conclusion

As in all others modules you only need to provide an ICallCommand within the DI container and you can start implementing your own modules. You can start now.