I have a server connect file that is receiving an HTTP post request as a webhook. Basically anytime a phonecall comes in through signalwire (twilio competitior) I have the data being sent to a sever connect file and it is being inserted into a database. No issues there it is working fine.
What I can’t figure out is how to trigger a modal (or any sort of alert) on the client side whenever a post request is sent to the sever connect file.
Basically the workflow would be:
Incoming HTTP post request from signal wire to server connect file -> read $_post and insert data into DB -> check to see if user with associated phone number is logged in -> if logged in then have a modal or alert popup on their current page with the posted data
Could someone point me in the right direction of how I can achieve this? I have a feeling it has to do with the “Set Value” server connect action but I am not sure.
as far as i understand you want to use sip session.
It will be difficult for you to do this with the webhook. To do this, you need to use a javascript library.
In this way, you can perform all kinds of SIP management.
Thank you for the reply but I am not trying to setup the actual phone call in the browser (I know I need to use SIP for that).
I am just trying to trigger an action on the client side from a server action when the webhook is being triggered from an external source. All I am wanting to display in the client side is some text data from the HTTP $_post call.
For that you would need to set up a websocket to listen for real time updates on server. This is not currently implemented in Wappler although it’s on the roadmap.
As a workaround you could use the scheduler to poll the database every x seconds and show a modal when a condition is met. It won’t be realtime but it’s that, implement sockets yourself or wait for the native implementation in Wappler.
The third option is server sent events which is similar to polling. You would need to build it yourself too.
Can you please tell me, how to make the workaround exactly? I can’t figure it out I don’t know, where to put the condition, where the modal should show.
It looks correctly, do you want to show the dialog on all connected clients? If you open the same page in 2 different browsers, does it then show up in the other browser? The emit should trigger the event on all connected clients, broadcast action triggers on all clients excepts the the sender.