1

I have a requirement to hang up the current phone call programmatically in Genesys Workspace Desktop edition. Here is what I have:

public class SomeService
{
    private readonly IEnterpriseServiceProvider _esp;

    public SomeService(IEnterpriseServiceProvider esp)
    {
        _esp = esp;
    }

    public void HangupCurrentCall()
    {
        var iv = _esp.Resolve<IInteractionVoice>();

        iv.Release();
    }
}

The code above is executing with no error, but the call is not being hung up.

Eric Scherrer
  • 3,328
  • 1
  • 19
  • 34

1 Answers1

2

You can't hangup current call just from enterprise service. WDE providing API for that. You can check from developer guide document. Actually you have two options to achieve this. First way using WDE API command calls. Second way using universal SDK (PSDK) to hangup current call. First of all you need to collect current call's interactionId. After that can call a command like that,

commandManager.CommandsByName["InteractionVoiceReleaseCall"].Insert(0, new CommandActivator()
            {
                CommandType = typeof(CustomCommand.ReleaseCall),
                Name = "InteractionVoiceReleaseCall"
            });     

You can find all commands list from WDE api guide. On your command type (class) you must return boolean. If you return false, its ok to continue, sending true like break the command.

Or you can directly execute a command like this;

IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("CommandParameter", interaction);
parameters.Add("Reasons", reasons);
parameters.Add("Extensions", extensions);
commandManager.GetChainOfCommandByName("InteractionVoiceReleaseCall").Execute();

As a SDK certificated developer, i always prefer PSDK(universal genesys sdk). You can retrieve current SIP Server connection and send request to it. Like this code block

IChannelService channelService = agent.EntrepriseService.Resolve<IChannelService>("channelService");
IClientChannel tServerChannel = channelService.ListChannels<Genesyslab.Platform.Voice.Protocols.TServerProtocol>().FirstOrDefault();

channelService.RegisterEvents(tServerChannel, new Action<Genesyslab.Enterprise.Model.Channel.IClientChannel>(ChannelEvent));

TServerProtocol tServerProtocol = tServerChannel.Protocol as TServerProtocol;

After this you have current connection on tserverPorotocol object. Then you can send a request to SIP Server.

Like this:

Genesyslab.Platform.Voice.Protocols.TServer.Requests.Voice.RequestReleaseCall releaseCall = Genesyslab.Platform.Voice.Protocols.TServer.Requests.Voice.RequestReleaseCall.Create();
releaseCall.ThisDN = "7000"; //(for example)(you can retrieve agent's DN from agent object)
releaseCall.ConnID = interaction.ConnectionId     // you can retrieve from interactionhandler event.

 tServerProtocol.Send(releaseCall);
 //or  tServerProtocol.Request(releaseCall); for async request. request return a ack message from the server.

I tried to explain basics. I hope its helpful. If you got a question about sip or etc. please let me know.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
orhun.begendi
  • 937
  • 3
  • 16
  • 31
  • 1
    Thank you Orhun, this was very helpful. I went with the PSDK approach since I couldn't get calling the command directly to work. Btw your variable "parameters" above is never used. Here is how I got the ThisDN: IMediaVoice voiceMedia = (IMediaVoice)_agent.Place.ListOfMedia.FirstOrDefault(x => x is IMediaVoice); request.ThisDN = voiceMedia.ConfDN.Number; Not sure if that is the best way, but it worked. – Eric Scherrer Feb 23 '17 at 19:58
  • 1
    Hi, Eric. Actually you can pass "parameters" with execute :) sorry for typos. Actually i wrote from mobile, i guess i forgot to add. :) Almost everyday I coding with genesys psdk. If you get agent's DN, you can send any request to servers and you can do what ever want to do. For example transfer,mute etc. Btw, WDE using unity container. You can use contructor injection method for resolve any interface. For example IAgent, inside IAgent, you can get DNs agent.Place.ConfPlace.DNs.FirstOrDefault(); like this. P.S: an agent can use multiple DNs(but for best practice always using one) – orhun.begendi Feb 24 '17 at 20:39
  • Cool thanks. I was wondering about multiple DN's but this is to support a legacy integration and there will never be more than one DN. – Eric Scherrer Feb 27 '17 at 19:44
  • 1
    For best practice always use one DN per place. Adding more than one DN its just increasing complexity. For best practice you can get active DN with the tserverprotocol property or agent property as well. just keep in mind, could be need in time (i hope not :) ) – orhun.begendi Feb 27 '17 at 19:47
  • I was able to get the command working, all I had to do was pass in the interaction (as you demonstrated above). Do you happen to know what command I need to invoke in order to Mark the interaction as closed? Basically I need to automatically select the disposition and click the check button for the user. I have tried a few different command chains and non of them hit my breakpoint. – Eric Scherrer Mar 02 '17 at 21:53
  • 1
    Regarding my above comment, the command chain to use is "BundleClose". – Eric Scherrer Mar 03 '17 at 18:25