public static async Task <EndUserAndAgentConversationMappingState> GetFromVso(int vsoId)
        {
            using (WorkItemTrackingHttpClient workItemTrackingHttpClient = VsoHelper.GetWorkItemTrackingHttpClient())
            {
                try
                {
                    TeamFoundation.WorkItemTracking.WebApi.Models.WorkItem workitem =
                        await workItemTrackingHttpClient.GetWorkItemAsync(vsoId);

                    return(new EndUserAndAgentConversationMappingState(vsoId.ToString(),
                                                                       workitem.Fields[VsoHelper.EndUserNameFieldName].ToString(),
                                                                       workitem.Fields[VsoHelper.EndUserIdFieldName].ToString(),
                                                                       workitem.Fields[VsoHelper.EndUserConversationIdFieldName].ToString(),
                                                                       workitem.Fields[VsoHelper.AgentConversationIdFieldName].ToString()));
                }
                catch (Exception ex)
                {
                    WebApiConfig.TelemetryClient.TrackException(ex, new Dictionary <string, string>
                    {
                        { "function", "CreateAConversation" },
                        { "debugNote", "error closing task" },
                        { "vsoId", vsoId.ToString() },
                    });

                    throw;
                }
            }
        }
        public async Task SaveInVso(string vsoId)
        {
            Uri uri = new Uri(VsoHelper.Uri);

            JsonPatchDocument patchDocument = new JsonPatchDocument
            {
                new JsonPatchOperation
                {
                    Operation = Operation.Add, Path = $"/fields/{VsoHelper.EndUserConversationIdFieldName}", Value = EndUserConversationId
                },
                new JsonPatchOperation
                {
                    Operation = Operation.Add, Path = $"/fields/{VsoHelper.AgentConversationIdFieldName}", Value = AgentConversationId
                },
                new JsonPatchOperation
                {
                    Operation = Operation.Add, Path = $"/fields/{VsoHelper.EndUserIdFieldName}", Value = EndUserId
                },
                new JsonPatchOperation
                {
                    Operation = Operation.Add, Path = $"/fields/{VsoHelper.EndUserNameFieldName}", Value = EndUserName
                },
            };

            using (WorkItemTrackingHttpClient workItemTrackingHttpClient = VsoHelper.GetWorkItemTrackingHttpClient())
            {
                try
                {
                    TeamFoundation.WorkItemTracking.WebApi.Models.WorkItem result =
                        await workItemTrackingHttpClient.UpdateWorkItemAsync(patchDocument, Convert.ToInt32(vsoId));

                    Trace.TraceInformation($"Project {vsoId} successfully updated. {this}");
                }
                catch (Exception ex)
                {
                    WebApiConfig.TelemetryClient.TrackException(ex, new Dictionary <string, string>
                    {
                        { "function", "SaveInVso" },
                        { "debugNote", "Failed to update project" },
                        { "vsoId", vsoId },
                    });
                    throw;
                }
            }
        }
        public static async Task <string> GetAgentConversationIdForVso(int vsoId)
        {
            using (WorkItemTrackingHttpClient workItemTrackingHttpClient = VsoHelper.GetWorkItemTrackingHttpClient())
            {
                try
                {
                    WorkItem workitem = await workItemTrackingHttpClient.GetWorkItemAsync(vsoId);

                    return((string)(workitem.Fields.TryGetValue(AgentConversationIdFieldName, out object conversationId)
                        ? conversationId
                        : ""));
                }
                catch (Exception ex)
                {
                    WebApiConfig.TelemetryClient.TrackException(ex, new Dictionary <string, string>
                    {
                        { "function", "GetAgentConversationIdForVso" },
                        { "vsoId", vsoId.ToString() },
                    });

                    throw;
                }
            }
        }