private async Task ProcessGoogleBusinessMessagingRequestAsync(GoogleBusinessRequest request, BotCallbackHandler logic)
        {
            var activity = RequestToActivity(request);
            var context  = new TurnContext(this, activity);

            await RunPipelineAsync(context, logic, default).ConfigureAwait(false);
        }
        private Activity RequestToMessageActivity(GoogleBusinessRequest request)
        {
            var activity = Activity.CreateMessageActivity() as Activity;

            activity      = SetGeneralActivityProperties(activity, request);
            activity.Text = request.Message?.Text ?? request.SuggestionResponse?.Text;
            return(activity);
        }
        public Activity RequestToActivity(GoogleBusinessRequest request)
        {
            if (request.Message != null || request.SuggestionResponse?.Type == "REPLY")
            {
                return(RequestToMessageActivity(request));
            }

            return(RequestToEventActivity(request));
        }
 private Activity SetGeneralActivityProperties(Activity activity, GoogleBusinessRequest request)
 {
     activity.ChannelId    = _options.ChannelId;
     activity.Id           = request.RequestId;
     activity.ServiceUrl   = _options.ServiceUrl;
     activity.Recipient    = new ChannelAccount(request.Agent);
     activity.From         = new ChannelAccount(request.ConversationId, request.Context.UserInfo?.DisplayName);
     activity.Conversation = new ConversationAccount(isGroup: false, id: request.ConversationId);
     activity.Timestamp    = DateTime.UtcNow;
     activity.ChannelData  = request;
     activity.Locale       = request.Context.ResolvedLocale;
     return(activity);
 }
        private Activity RequestToEventActivity(GoogleBusinessRequest request)
        {
            var activity = Activity.CreateEventActivity() as Activity;

            activity = SetGeneralActivityProperties(activity, request);

            if (request.UserStatus != null)
            {
                if (request.UserStatus.IsTyping)
                {
                    activity.Name  = "IsTyping";
                    activity.Value = request;
                }

                if (request.UserStatus.RequestedLiveAgent)
                {
                    activity.Name  = "RequestedLiveAgent";
                    activity.Value = request;
                }
            }
            else if (request.Receipts != null)
            {
                activity.Name  = request.Receipts.Receipts?.FirstOrDefault()?.ReceiptType;
                activity.Value = request.Receipts.Receipts?.FirstOrDefault()?.Message;
            }
            else if (request.SuggestionResponse != null)
            {
                activity.Name  = $"SuggestionResponse";
                activity.Value = request.SuggestionResponse;
            }
            else if (request.SurveyResponse != null)
            {
                activity.Name  = $"SurveyResponse";
                activity.Value = request.SurveyResponse;
            }
            else
            {
                activity.Name  = "UNKNOWN";
                activity.Value = request;
            }

            return(activity);
        }
 public virtual Activity RequestToActivity(GoogleBusinessRequest request)
 {
     return(_requestMapper.RequestToActivity(request));
 }