public bool MessageHandled(dynamic message)
        {
            var result = message.account_linking != null;

            if (result)
            {
                string senderID    = message.sender.id;
                var    recipientID = message.recipient.id;

                string status   = message.account_linking.status;
                string authCode = message.account_linking.authorization_code;

                _logger.LogInformation(
                    string.Format("Received account link event with for user {0} with status {1} " +
                                  "and auth code {2} ", senderID, status, authCode));

                if (authCode == "1")
                {
                    var flow        = new DialogueFlow(senderID);
                    var messageData = flow.GetCaseThree();
                    _messageSender.CallSendAPI(messageData);
                }

                else if (authCode == "2")
                {
                    var flow        = new DialogueFlow(senderID);
                    var messageData = flow.GetSuccessCase();
                    _messageSender.CallSendAPI(messageData);
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public bool MessageHandled(dynamic message)
        {
            var result = message.postback != null;

            if (result)
            {
                string senderID       = message.sender.id;
                string recipientID    = message.recipient.id;
                string timeOfPostback = message.timestamp;

                // The 'payload' param is a developer-defined field which is set in a postback
                // button for Structured Messages.
                var    payload  = message.postback.payload;
                string pyldText = payload.ToString();

                _logger.LogInformation(
                    string.Format("Received postback for user {0} and page {1} with payload '{2}' " +
                                  "at {3}", senderID, recipientID, pyldText, timeOfPostback));


                if (pyldText == "1")
                {
                    var flow        = new DialogueFlow(senderID);
                    var messageData = flow.GetCaseTwo();
                    _messageSender.CallSendAPI(messageData);
                }
                else if (pyldText == "5")
                {
                    var flow        = new DialogueFlow(senderID);
                    var messageData = flow.GetCaseThree();
                    _messageSender.CallSendAPI(messageData);
                }
                else if (pyldText == "6")
                {
                    _messageSender.SendTextMessage(senderID, "Thank you!");
                }
            }
            return(result);
        }