Recently I was working on an application endpoint that records a Lync audio call. I got that working fine but when a Lync user called another user and the call then got redirected to my application the name in the Communicator window would change to the name that my app was registered as. Not a good thing as I wanted my callers to think they were leaving a voice mail for the user.
This is a common thing to do in a Back to Back call scenario where you impersonate a different user for the second leg (which you originate in your app). But my call was actually terminating with my app so there was no second leg that I was connecting to. I wasn’t sure if this was possible so I went digging around in the debugger and IntelliSense (both are my best friends). This is what I came up with and it works great..
private static void AudioVideoCallReceived(object sender, CallReceivedEventArgs<AudioVideoCall> e)
Debug.Assert(e != null, “e != null”);
Debug.Assert(e.RequestData != null, “e.RequestData != null”);
if (e.RequestData != null)
e.Call.Conversation.Impersonate(e.TransferredBy, e.Call.Conversation.LocalParticipant.PhoneUri, e.Call.Conversation.LocalParticipant.DisplayName);
StartWorkflow(e.Call, e.RequestData, e.TransferredBy.ToString(), e.RemoteParticipant.ToString());
Now the caller only sees the original caller’s name and status when talking to my application. Note that the values don’t have to resolve to real addresses but they do need to be properly formatted.