Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send only once one message? #134

Closed
sgaseretto opened this issue Dec 28, 2017 · 3 comments
Closed

How to send only once one message? #134

sgaseretto opened this issue Dec 28, 2017 · 3 comments

Comments

@sgaseretto
Copy link

When I run the examples for messenger, once I send something to the bot, it starts spamming the same thing until I stop the server, how do I send a message only once and wait for the user to respond?
Here is an example of what I'm talking:
img_3630

@wtflink
Copy link
Member

wtflink commented Dec 28, 2017

Seems like your bot keep receiving the "message_echoes" event.
Set your webhook properly or filter onEcho event to stop the bot from self responding.
You can also check the official webhook setting documents for more info.
ref: https://developers.facebook.com/docs/messenger-platform/webhook

@sgaseretto
Copy link
Author

Thanks a lot, it was the "message_echoes" event

@chentsulin
Copy link
Collaborator

Or you can filter echo events explicitly in the handler:

bot.onEvent(async context => {
  if (!context.event.isEcho) {
    await context.sendText('Hello World');
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants