private static void OnConversationIdleCheckEvent(object source, ElapsedEventArgs e)
 {
     foreach (var externalConversationId in ConversationRouter.Keys)
     {
         var conversation = ConversationRouter[externalConversationId];
         if (DateTime.Now - conversation.LastConversationUpdateTime >
             TimeSpan.FromMinutes(ConversationEndAfterIdleTimeInMinute))
         {
             // conversation inactive for > ConversationEndAfterIdleTimeInMinute, removing from s_conversationRouter
             // If same external conversation active again, a new bot conversation will be created
             conversation = null;
             ConversationRouter.Remove(externalConversationId);
         }
     }
 }
 /// <summary>
 /// Search if an external Azure Bot Service channel conversation is
 /// connected to an existing Power Virtual Agent bot conversation
 /// </summary>
 /// <returns>true if conversation mapping exists, otherwiser false</returns>
 /// <param name="externalCID">external Azure Bot Service channel conversation ID</param>
 public bool ConversationExists(string externalCID)
 {
     return(ConversationRouter.ContainsKey(externalCID));
 }
 /// <summary>
 /// Retrive or start a Power Virtual Agent bot conversation
 /// for a given external Azure Bot Service channel conversation
 /// </summary>
 /// <returns>Power Virtual Agent bot conversation</returns>
 /// <param name="externalCID">external Azure Bot Service channel conversation ID</param>
 public async Task <RelayConversation> GetOrCreateBotConversationAsync(string externalCID, IBotService botService)
 {
     return(ConversationRouter.TryGetValue(externalCID, out var botConversation) ?
            botConversation : await StartBotConversationAsync(externalCID, botService));
 }