public function processEvent($event) { // Currently, we only handle message and postback if (!isset($event->message) && !isset($event->postback)) { return; } if (isset($event->message)) { $this->message = $event->message; } // If current message is send from Lead if (!$this->conversation->has('lead_id') && $event->sender->id != Config::get('page_id')) { $this->conversation->set('lead_id', $event->sender->id); // Save lead data if not exists. $this->storage->pull($event->sender->id); } DynamicParser::support(['type' => 'callback', 'callback' => function ($content) { return @call_user_func_array($content, [$this, $this->getLeadId(), $this->getReceivedText()]); }]); $type_pattern = $this->request->getTypeAndPattern($event); // We'll check to response intended action first if ($this->responseIntendedAction()) { return; } $nodes = $this->findNodes($type_pattern['type'], $type_pattern['pattern']); $this->response($nodes); }