Bridge Communications

Thursday, July 30, 2015

Basic Call Control Using the Lync Client SDK VI

Last weeks blog was focused on the supervised transfer capability of the Lync (Skype for Business) Client SDK.  This week we will examine another kind of transfer, "The Safe Transfer".  So what in the world is a "safe transfer" and when would you use it?

Safe Transfer - A safe transfer is designed for areas that require high customer service, where the calls need to talk to other humans, not voicemail boxes, response groups, etc.  A safe transfer in Lync is a blind transfer, but instead of following call routing if the destination doesn't answer, returns to operator to be serviced again by another human.

So how do we execute a blind transfer with the safe option?  If you recall our code a few blogs ago on how to blind transfer, you will remember the parameter transfer options.  It is located here.




public static void BlindTransferCall(Conversation c, Contact num, TransferOptions topt)
        {
            if (c == null)
                return;

            if (c.Modalities[ModalityTypes.AudioVideo].CanInvoke(ModalityAction.ConsultAndTransfer))
            {

                List<string> _context = new List<string>();
                Object[] asyncState = { ModalityState.Transferring, _context, c.Modalities[ModalityTypes.AudioVideo] };

                c.Modalities[ModalityTypes.AudioVideo].BeginTransfer(num, topt, myar =>
                {

                    try
                    {

                        Object[] _asyncState = (Object[])myar.AsyncState;
                        ModalityState ms = (ModalityState)_asyncState[0];
                        IList<string> _contextProperties = (List<string>)_asyncState[1];

                        c.Modalities[ModalityTypes.AudioVideo].EndTransfer(out ms, out _contextProperties, myar);

                    }
                    catch (ArgumentException)
                    {
                         Console.WriteLine("Entered Uri is not valid " + num.Uri);
                    }
                    catch (ItemNotFoundException)
                    {
                         Console.WriteLine("Entered Uri could not be resolved to a Contact " + num.Uri);
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
                        string er;
                        er = "BlindTransferCall: Error Trapped in " + Dlib.ProgramSource + ".\r\n";
                        er = er + trace.GetFrame(0).GetMethod().Name + "\r\n" + ex.Message.ToString();
                        er = er + "Line: " + trace.GetFrame(0).GetFileLineNumber();
                        er = er + "Column: " + trace.GetFrame(0).GetFileColumnNumber();
                        Console.WriteLine(er);
                    }


                }, asyncState);
            }
        }

As you can see turning a blind transfer into a safe blind transfer is an easy as changing 1 line of code.  Stay tuned next week for some more advanced call control functions available in the Lync (Skype for Business) client sdk.

Doug Routledge, C# Lync, Skype for Business, SQL, Exchange, UC Developer  BridgeOC
Twitter - @droutledge @ndbridge



No comments:

Post a Comment