CasperLaiTW / laravel-fb-messenger

Laravel Facebook Messenger Provider
MIT License
105 stars 27 forks source link

How can I send the respond later on? #63

Closed m7vm7v closed 7 years ago

m7vm7v commented 7 years ago

Hi, When someone is messaging I am receiving and storing the ID that facebook has provided.

How can I send to that user a message from my application.

I have tryed:

In my controller I have:

$fbMessanger = new FacebookMessageHandler();
$fbMessanger->sendPublishedMessage($user->facebook_id);

in FacebookMessageHandler:

public function sendPublishedMessage($user){
        $this->send(new Text($user, 'published'));
    }

But when I trigger it I got: NotCreateBotException in BaseHandler.php line 61

I need to have the option to message the facebook user from my application later on. Now it receives the automated answer but I need to extend it by answering later on.

Would that be possible with this package?

Thanks

CasperLaiTW commented 7 years ago

Hi @m7vm7v

Sure, you can send message by yourself

$fbMessanger = new FacebookMessageHandler();
$fbMessanger->createBot(config('fb-messenger.app_token'));
$fbMessanger->sendPublishedMessage($user->facebook_id);

you miss the line 2 :)

m7vm7v commented 7 years ago

Thanks mate. That was it.