public async Task <string> SaveUserFeedback([FromBody] UserfeedbackInfo data)
        {
            try
            {
                _telemetry.TrackEvent("SaveUserFeedback");
                FeedbackDataRepository feedbackDataRepository = new FeedbackDataRepository(_configuration, _telemetry);
                // Check if this is user's second feedback
                FeedbackDataEntity feebackData = await feedbackDataRepository.GetReflectionFeedback(data.reflectionId, data.emailId);

                if (data.feedbackId == 0)
                {
                    await feedbackDataRepository.DeleteFeedback(feebackData);
                }
                else
                {
                    if (feebackData != null && data.emailId == feebackData.FeedbackGivenBy)
                    {
                        feebackData.Feedback = data.feedbackId;
                        await feedbackDataRepository.CreateOrUpdateAsync(feebackData);
                    }
                    else
                    {
                        await _dbHelper.SaveReflectionFeedbackDataAsync(data);
                    }
                }
                return("true");
            }
            catch (Exception e)
            {
                _telemetry.TrackEvent("SaveUserFeedback Exception " + e);
                return("false");
            }
        }
        /// <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>
        /// On Teams Task Module Fetch Async.
        /// </summary>
        /// <param name="turnContext">turnContext.</param>
        /// <param name="taskModuleRequest">taskModuleRequest.</param>
        /// <param name="cancellationToken">cancellationToken.</param>
        /// <returns>.</returns>
        protected override async Task <TaskModuleResponse> OnTeamsTaskModuleFetchAsync(ITurnContext <IInvokeActivity> turnContext, TaskModuleRequest taskModuleRequest, CancellationToken cancellationToken)
        {
            _telemetry.TrackEvent("OnTeamsTaskModuleFetchAsync");
            try
            {
                ReflctionData            reldata = JsonConvert.DeserializeObject <ReflctionData>(taskModuleRequest.Data.ToString());
                FeedbackDataRepository   feedbackDataRepository   = new FeedbackDataRepository(_configuration, _telemetry);
                ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry);
                RecurssionDataRepository recurssionDataRepository = new RecurssionDataRepository(_configuration, _telemetry);
                QuestionsDataRepository  questiondatarepository   = new QuestionsDataRepository(_configuration, _telemetry);
                var response = new UserfeedbackInfo();
                var name     = (turnContext.Activity.From.Name).Split();
                response.userName = name[0] + ' ' + name[1];
                response.emailId  = await _dbHelper.GetUserEmailId(turnContext);

                var reflectionid = reldata.datajson.ReflectionId;
                var feedbackId   = reldata.datajson.FeedbackId;
                response.reflectionId = reflectionid;
                response.feedbackId   = feedbackId;

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

                TaskInfo taskInfo = new TaskInfo();
                if (response.feedbackId != 0)
                {
                    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.question     = question.Question;
                        taskInfo.postCreateBy = reflectData.CreatedBy;
                        taskInfo.privacy      = reflectData.Privacy;
                        taskInfo.reflectionID = reflectData.ReflectionID;
                        Attachment attachment = new Attachment()
                        {
                            ContentType = AdaptiveCard.ContentType,
                            Content     = adaptiveCard,
                        };
                        var reply = Activity.CreateMessageActivity();
                        reply.Attachments.Add(attachment);
                        if (reflectData.MessageID == null)
                        {
                            var result = turnContext.SendActivityAsync(reply, cancellationToken);
                            reflectData.MessageID = result.Result.Id;

                            // update messageid 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());
                    }
                }

                return(new TaskModuleResponse
                {
                    Task = new TaskModuleContinueResponse
                    {
                        Value = new TaskModuleTaskInfo()
                        {
                            Height = 600,
                            Width = 600,
                            Title = "Track how you're feeling every day.",
                            Url = reldata.data.URL + reflectionid + '/' + feedbackId + '/' + response.userName,
                        },
                    },
                });
            }
            catch (Exception ex)
            {
                _telemetry.TrackException(ex);
                return(null);
            }
        }