Lessons Learned: impersonating a user
As I mentioned in Lessons Learned: passing parameters to your workflow I'm doing a series of blog posts on things that I learned while working on my latest UCMA IVR project. The app recorded the caller's messsage and also allowed the voice mailbox owner to record a custom greeting.
One of the problems I originally encountered occurred when the remote caller was a Lync user and was placing a Lync audio call to another Lync user. When that happened the caller would see something like this -
At this point in the call it is just a call between two Lync users and everything looks and works as you would expect. The problem occurs when the called party doesn't answer or manually redirects the call to voice mail. When my application took over the call the caller's Lync window would show the name of my app and look like this -
Not exactly what I wanted the caller to see. The caller should see the name of the person they are calling throughout the life of the call. Fortunately UCMA has a facility that makes that simple. All I needed to do was have my application impersonate the called party and that can be dome with a s single line of code. I added this to myAudioVideoCallReceived event handler
e.Call.Conversation.Impersonate(e.TransferredBy, e.Call.Conversation.LocalParticipant.PhoneUri, e.Call.Conversation.LocalParticipant.DisplayName);
That code told my application to impersonate the called party. I only wish that this method was a little better documented. All references that I found were in the scope of a B2B call where the UCMA application sits in the middle between the calling party and the called party. That wasn't the case with my app as it is an endpoint. I wasn't sure if it would work in my case but it did.Note that for the third parameter I used the caled party's display name but that parameter is just a simple string and you could use it to cause any text to appear.
Simple and easy.