diff --git a/src/Conversation/AutoStop.php b/src/Conversation/AutoStop.php index 5438d11..eca5976 100644 --- a/src/Conversation/AutoStop.php +++ b/src/Conversation/AutoStop.php @@ -15,6 +15,7 @@ public static function run($event) return false; if ($event->sender->id == Conversation::get('page_id')) { + $administrator_text = null; $lead_id = $event->recipient->id; diff --git a/src/MessengerBot.php b/src/MessengerBot.php index d06a33d..9170aff 100644 --- a/src/MessengerBot.php +++ b/src/MessengerBot.php @@ -184,25 +184,24 @@ public function processEvent($event) if (isset($event->postback)) { $this->postback = $event->postback; } - - // If auto stop is run and it return true. Terminate - if (AutoStop::run($event)) { - return null; - } $this->conversation->set('lead_id', $event->sender->id); $this->conversation->set('page_id', $event->recipient->id); - // If current message is sent from Lead - if ( ! isset($event->message->is_echo)) { - - if (AutoStop::isStopped()) { - return null; - } - } else { + // If current message is sent from Page + if (isset($event->message->is_echo)) { $this->conversation->set('lead_id', $event->recipient->id); $this->conversation->set('page_id', $event->sender->id); } + + // If auto stop is run and it return true. Terminate + if (AutoStop::run($event)) { + return null; + } + + if (AutoStop::isStopped()) { + return null; + } $this->setAccessToken();