instedd / surveda

InSTEDD Surveda
https://instedd.org/technologies/surveda-mobile-surveys/
GNU General Public License v3.0
17 stars 6 forks source link

Respect Survey schedule when sending SMS messages #2283

Open ysbaddaden opened 1 year ago

ysbaddaden commented 1 year ago

Nuntium doesn't have time schedules like Verboice has, so Surveda previously didn't have any mean to prevent messages from being sent after hours, that is after the scheduled time window ended for the day.

The channel-broker didn't fix this issue. It acts as a dam to avoid spamming and overflowing the Nuntium servers, but when the time window ends for the day, knowing nothing about the scheduled time for contacts, all messages queued during the time window will be sent, until the queue is emptied. This will happen at some point because the survey-broker noticed that the time window has ended and won't poll the survey anymore.

Surveda now as a way to fix the issue. Ask.Runtime.Channel can compute and pass the not_before and not_after attributes for the SMS modes, as it does for IVR mode, and pass them to Ask.Runtime.ChannelBroker.ask, allowing the channel-broker to respect the scheduled time: keep messages in queue until not_before and skip messages when not_after is reached.

Of course, this has no impact on currently active contacts (responses are sent immediately, regarless of the scheduled time, only on new contacts and retries).

ysbaddaden commented 1 year ago

I removed the "bug" label, because even though we don't respect scheduled hours for SMS messages, we didn't have the mean to fix the the problem before. We now have the ability to finally implement the feature.

ysbaddaden commented 1 year ago

Related #2288