Charca / bootbot

Facebook Messenger Bot Framework for Node.js
MIT License
974 stars 253 forks source link

Allow a regex to postback callbacks #87

Closed mraaroncruz closed 1 year ago

mraaroncruz commented 6 years ago

Can we do this in a way that doesn't muddle the api for bot.on?

Some ideas:

bot.on(/postback:PRODUCT[0-9]{1,3}/, (payload, chat) => {})

bot.postback(/PRODUCT[0-9]{1,3}/, (payload, chat) => {})

bot.on('postback', /postback:PRODUCT[0-9]{1,3}/, (payload, chat) => {})

Anyone else have any API ideas here?

Pandawan commented 6 years ago

👍 I also need this for my bot. I need to make buttons that allow you to unsubscribe from a given topic and wanted to do so like this:

bot.on(/postback:UNSUB_(\S*)/i, (payload, chat, data) => {

But it seems like that is not available... Please add!