jgorset / facebook-messenger

Definitely the best way to make Bots on Facebook Messenger with Ruby
MIT License
962 stars 211 forks source link

message.reply + sleep has unwanted repeats #223

Closed adeprem closed 5 years ago

adeprem commented 6 years ago

Hi everyone, I'm trying to have a sleep function in my code in order to let the user listen to the audio file I'm sending him with message.reply(...). The problem is that the file keeps sending until the sleep function is finally done (it sent 9 times in the 5 minutes span). Anyone knows what the reason might be? Here is what the code looks like. message.reply( attachment: { type: 'audio', payload: { url: 'https://s3.eu-west-3.amazonaws.com/botmessenger/acceptation+-+Embrasser+le+mauvais+et+offrir+le+bon.mp3' } } ) sleep(5.minutes) say(sender_id, FEEDBACK_QUESTION, FEEDBACK) #demande feedback

Thank you :)

amrutjadhav commented 6 years ago

@adeprem I think you should not have a sleep call in bot application. This will pause the current instance of application for the specified time. Because of this, current instance will not be able to serve next request which is not ideal in bot application. What can you do here is that, send the feedback message immediately after the audio file. Anyhow, you can't predict whether the user listened to the song within the 5 minutes or not.

jgorset commented 5 years ago

This seems resolved, so I'm closing it!