/// <summary>
        /// On message activity sync.
        /// </summary>
        /// <param name="turnContext">turnContext.</param>
        /// <param name="cancellationToken">cancellationToken.</param>
        /// <returns>.</returns>
        protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            _telemetry.TrackEvent("OnMessageActivityAsync");

            try
            {
                FeedbackDataRepository   feedbackDataRepository   = new FeedbackDataRepository(_configuration, _telemetry);
                ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry);
                RecurssionDataRepository recurssionDataRepository = new RecurssionDataRepository(_configuration, _telemetry);
                QuestionsDataRepository  questiondatarepository   = new QuestionsDataRepository(_configuration, _telemetry);

                if (turnContext.Activity.Value != null)
                {
                    var response = JsonConvert.DeserializeObject <UserfeedbackInfo>(turnContext.Activity.Value.ToString());
                    var reply    = Activity.CreateMessageActivity();
                    if (response.type == ReflectConstants.SaveFeedBack)
                    {
                        var name = (turnContext.Activity.From.Name).Split();
                        response.userName = name[0] + ' ' + name[1];
                        response.emailId  = await _dbHelper.GetUserEmailId(turnContext);

                        // Check if this is user's second feedback
                        FeedbackDataEntity feebackData = await feedbackDataRepository.GetReflectionFeedback(response.reflectionId, response.emailId);

                        if (feebackData != null && response.emailId == feebackData.FeedbackGivenBy)
                        {
                            feebackData.Feedback = response.feedbackId;
                            await feedbackDataRepository.CreateOrUpdateAsync(feebackData);
                        }
                        else
                        {
                            await _dbHelper.SaveReflectionFeedbackDataAsync(response);
                        }

                        try
                        {
                            // Check if message id is present in reflect data
                            ReflectionDataEntity reflectData = await reflectionDataRepository.GetReflectionData(response.reflectionId);

                            QuestionsDataEntity question = await questiondatarepository.GetQuestionData(reflectData.QuestionID);

                            Dictionary <int, List <FeedbackDataEntity> > feedbacks = await feedbackDataRepository.GetReflectionFeedback(response.reflectionId);

                            var      adaptiveCard = _cardHelper.FeedBackCard(feedbacks, response.reflectionId, question.Question);
                            TaskInfo taskInfo     = new TaskInfo();
                            taskInfo.question     = question.Question;
                            taskInfo.postCreateBy = reflectData.CreatedBy;
                            taskInfo.privacy      = reflectData.Privacy;
                            taskInfo.reflectionID = reflectData.ReflectionID;
                            Attachment attachment = new Attachment()
                            {
                                ContentType = AdaptiveCard.ContentType,
                                Content     = adaptiveCard
                            };
                            reply.Attachments.Add(attachment);
                            if (reflectData.MessageID == null)
                            {
                                var result = turnContext.SendActivityAsync(reply, cancellationToken);
                                reflectData.MessageID = result.Result.Id;
                                // update message-id in reflection table
                                await reflectionDataRepository.InsertOrMergeAsync(reflectData);
                            }
                            else
                            {
                                reply.Id = reflectData.MessageID;
                                await turnContext.UpdateActivityAsync(reply);
                            }
                        }
                        catch (System.Exception e)
                        {
                            _telemetry.TrackException(e);
                            Console.WriteLine(e.Message.ToString());
                        }
                    }
                }
                else
                {
                    await turnContext.SendActivityAsync(MessageFactory.Text($"Hello from Olga."), cancellationToken);
                }
            }
            catch (Exception ex)
            {
                _telemetry.TrackException(ex);
            }
        }
        /// <summary>
        /// RunJob.
        /// </summary>
        /// <param name="state">state.</param>
        private async void RunJob(object state)
        {
            _telemetry.TrackEvent("RunJob");
            try
            {
                ChannelAccount   channelAccount = new ChannelAccount(_configuration["MicrosoftAppId"]);
                Attachment       attachment     = new Attachment();
                TeamsChannelData channelData    = new TeamsChannelData()
                {
                    Notification = new NotificationInfo(true)
                };
                RecurssionDataRepository recurssionDataRepository = new RecurssionDataRepository(_configuration, _telemetry);
                ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry);
                QuestionsDataRepository  questiondatarepository   = new QuestionsDataRepository(_configuration, _telemetry);

                var recurssionData = await recurssionDataRepository.GetAllRecurssionData();

                foreach (RecurssionDataEntity recurssionDataEntity in recurssionData)
                {
                    var reflectionData = await reflectionDataRepository.GetReflectionData(recurssionDataEntity.ReflectionID);

                    var question = await questiondatarepository.GetQuestionData(reflectionData.QuestionID);

                    TaskInfo taskInfo = new TaskInfo();
                    taskInfo.question     = question.Question;
                    taskInfo.postCreateBy = reflectionData.CreatedBy;
                    taskInfo.privacy      = reflectionData.Privacy;
                    taskInfo.reflectionID = reflectionData.ReflectionID;
                    var        newPostCard           = _cardHelper.CreateNewReflect(taskInfo);
                    Attachment newPostCardAttachment = new Attachment()
                    {
                        ContentType = AdaptiveCard.ContentType,
                        Content     = newPostCard
                    };
                    var        PostCardFeedback           = _cardHelper.FeedBackCard(new Dictionary <int, List <FeedbackDataEntity> >(), taskInfo.reflectionID, taskInfo.question);;
                    Attachment PostCardFeedbackAttachment = new Attachment()
                    {
                        ContentType = AdaptiveCard.ContentType,
                        Content     = PostCardFeedback
                    };
                    var proactiveNotification = await new ProactiveMessageHelper(_configuration).SendChannelNotification(channelAccount, reflectionData.ServiceUrl, reflectionData.ChannelID, "", newPostCardAttachment);
                    if (proactiveNotification.IsSuccessful && proactiveNotification.MessageId != null)
                    {
                        reflectionData.ReflectMessageId = proactiveNotification.MessageId.Split("=")[1];
                        var feedbackproactivemessage = await new ProactiveMessageHelper(_configuration).SendChannelNotification(channelAccount, reflectionData.ServiceUrl, reflectionData.ChannelID, "", PostCardFeedbackAttachment, reflectionData.ReflectMessageId);
                        if (feedbackproactivemessage.IsSuccessful && proactiveNotification.MessageId != null)
                        {
                            reflectionData.MessageID = feedbackproactivemessage.MessageId;
                            await _dbHelper.UpdateReflectionMessageIdAsync(reflectionData);
                        }
                    }

                    var calculatedNextExecutionDateTime = _dbHelper.GetCalculatedNextExecutionDateTimeAsync(recurssionDataEntity);
                    recurssionDataEntity.NextExecutionDate = null;
                    await recurssionDataRepository.CreateOrUpdateAsync(recurssionDataEntity);

                    if (calculatedNextExecutionDateTime != null)
                    {
                        ReflectionDataEntity newreflectionDataEntity = new ReflectionDataEntity();
                        RecurssionDataEntity newRecurssionDataEntity = new RecurssionDataEntity();
                        var reflectionid = Guid.NewGuid();
                        var recurrsionid = Guid.NewGuid();
                        newreflectionDataEntity                = reflectionData;
                        newreflectionDataEntity.RowKey         = Guid.NewGuid().ToString();
                        newreflectionDataEntity.ReflectionID   = reflectionid;
                        newreflectionDataEntity.RefCreatedDate = DateTime.Now;
                        newreflectionDataEntity.RecurrsionID   = recurrsionid;
                        await reflectionDataRepository.CreateAsync(newreflectionDataEntity);

                        newRecurssionDataEntity                   = recurssionDataEntity;
                        newRecurssionDataEntity.RowKey            = Guid.NewGuid().ToString();
                        newRecurssionDataEntity.ReflectionID      = reflectionid;
                        newRecurssionDataEntity.CreatedDate       = DateTime.Now;
                        newRecurssionDataEntity.RecurssionID      = recurrsionid;
                        newRecurssionDataEntity.NextExecutionDate = calculatedNextExecutionDateTime;
                        await recurssionDataRepository.CreateAsync(newRecurssionDataEntity);
                    }
                }
            }
            catch (Exception ex)
            {
                _telemetry.TrackException(ex);
            }
        }