Alert when record added to a collection (for Twilio integration)

Is it possible to add some time of event listener to an Appery database collection so the app can then take an action when a new record is created?

I'm trying to integrate SMS text features into my app so the user can text a customer AND receive a response back from that text (and send subsequent texts..essentially a chat feature) directly within the app. I already have the framework in place to send texts from the app via the Twilio plugin, but it's the receiving part that I'm struggling with.

I can setup Twilio to post the response back to Appery via a webhook and write it to a collection, but now I need to figure out how to pick that information up in the app in real-time.

I could have the app periodically call the collection through the API to grab any new records, but I'm concerned about the performance (and cost) of continuously calling the database. Also I can't do a push notification as my app is only setup for the web (PWA).

That's why I was hoping there may be a way to setup an event listener so I would only have to call the collection when the new record is added as opposed to running the API pulls continuously.

Any thoughts on how this could be acheived, and/or other suggestion on integrating a chat like feature via Twilio, would be greatly appreciated.

1 person has
this question