Trigger Modal/Alert Client Side from Server Connect Webhook

Hey everyone,

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.

Thanks for any help in advance!

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.

That was exactly what i was loking for thank you! Server sent events will work perfectly, always helps figuring out what keyword to google :slight_smile:

1 Like

Can you please tell me, how to make the workaround exactly? I can’t figure it out :frowning: I don’t know, where to put the condition, where the modal should show.

Just use a websocket on the client and server. Emit on server action and shoe modal (or whatever) when event fires on the client. No workaround needed

I don’t know what I’m doing wrong, but it’s not working. See screenshots. Socket is created,

API/post is created with emit at the end

and client side has socket with event action to show modal.

The scenario is - someone post to api and once the post is done, I want to show modal on the client side. Did I make a mistake somewhere, please?

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.

It looks correctly to me too, but it’s not working and I’m going crazy about this “easy” function. I don’t know, where is the problem.

Did you test it with 2 separate browsers? Also with devtools you can see websocket traffic (Network tab), does it show anything there?