/// <summary> /// Create a new ticket from the input. /// </summary> /// <param name="message">A message in a conversation.</param> /// <param name="data">Represents the submit data associated with the Ask An Expert card.</param> /// <param name="member">Teams channel account detailing user Azure Active Directory details.</param> /// <param name="ticketsProvider">Tickets Provider.</param> /// <returns>TicketEntity object.</returns> private static async Task <TicketEntity> CreateTicketAsync( IMessageActivity message, AskAnExpertCardPayload data, TeamsChannelAccount member, ITicketsProvider ticketsProvider) { TicketEntity ticketEntity = new TicketEntity { TicketId = Guid.NewGuid().ToString(), Status = (int)TicketState.UnAssigned, DateCreated = DateTime.Now, Title = data.Title, Description = data.Description, RequesterName = member.Name, RequesterUserPrincipalName = member.UserPrincipalName, RequesterGivenName = member.GivenName, RequesterConversationId = message.Conversation.Id, LastModifiedByName = message.From.Name, LastModifiedByObjectId = message.From.AadObjectId, UserQuestion = data.UserQuestion, KnowledgeBaseAnswer = data.KnowledgeBaseAnswer, Subject = data.Project, }; await ticketsProvider.UpsertTicketAsync(ticketEntity).ConfigureAwait(false); return(ticketEntity); }
/// <summary> /// Create a new ticket from the input. /// </summary> /// <param name="currentLanguageCode">Current applicable language code.</param> /// <param name="message">A message in a conversation.</param> /// <param name="data">Represents the submit data associated with the Ask An Expert card.</param> /// <param name="member">Teams channel account detailing user Azure Active Directory details.</param> /// <param name="ticketsProvider">Tickets Provider.</param> /// <returns>TicketEntity object.</returns> private static async Task <TicketEntity> CreateTicketAsync( string currentLanguageCode, IMessageActivity message, AskAnExpertCardPayload data, TeamsChannelAccount member, ITicketsProvider ticketsProvider) { IList <TicketEntity> ticketList = await ticketsProvider.GetTicketCountAsync(); TicketEntity ticketEntity = new TicketEntity { LanguageCode = currentLanguageCode, TicketId = (10000 + ticketList.Count).ToString(), // Guid.NewGuid().ToString(), Status = (int)TicketState.UnAnswered, DateCreated = DateTime.UtcNow, Title = data.Title, Description = data.Description, RequesterName = member.Name, RequesterUserPrincipalName = member.UserPrincipalName, RequesterGivenName = member.GivenName, RequesterConversationId = message.Conversation.Id, LastModifiedByName = message.From.Name, LastModifiedByObjectId = message.From.AadObjectId, UserQuestion = data.UserQuestion, KnowledgeBaseAnswer = data.KnowledgeBaseAnswer, KnowledgeBaseQuestion = data.KnowledgeBaseQuestion, }; await ticketsProvider.UpsertTicketAsync(ticketEntity).ConfigureAwait(false); return(ticketEntity); }
/// <summary> /// Create a new ticket from the input. /// </summary> /// <param name="message">A message in a conversation.</param> /// <param name="data">Represents the submit data associated with the Ask An Expert card.</param> /// <param name="member">Teams channel account detailing user Azure Active Directory details.</param> /// <param name="ticketsProvider">Tickets Provider.</param> /// <returns>TicketEntity object.</returns> private static async Task <TicketEntity> CreateTicketAsync( IMessageActivity message, AskAnExpertCardPayload data, TeamsChannelAccount member, ITicketsProvider ticketsProvider) { //AtBot Conceirge Support //Boolean as to whether this is the Teams channel. If not, we assume bot is being interfaced as an AtBot Agent bool isTeamsChannel = message.ChannelId == "msteams"; ChannelAccount agentUser = message.From; //When creating a ticket from the bot acting as an agent, the requestor information will be limited to the UPN. Additional graph calls //will be needed to pull AAD GUID and display name. TicketEntity ticketEntity = new TicketEntity { TicketId = Guid.NewGuid().ToString(), Status = (int)TicketState.Open, DateCreated = DateTime.UtcNow, Title = data.Title, Description = data.Description, RequesterName = isTeamsChannel ? member.Name : agentUser.Name, RequesterUserPrincipalName = isTeamsChannel ? member.UserPrincipalName : agentUser.Name, RequesterGivenName = isTeamsChannel ? member.GivenName : agentUser.Name, RequesterConversationId = message.Conversation.Id, LastModifiedByName = message.From.Name, LastModifiedByObjectId = message.From.AadObjectId, UserQuestion = data.UserQuestion, KnowledgeBaseAnswer = data.KnowledgeBaseAnswer, }; await ticketsProvider.UpsertTicketAsync(ticketEntity).ConfigureAwait(false); return(ticketEntity); }