Redirecting via webhook

Hi,

I have a problem:

I have a details page that triggers a make-webhook via a api-call in a button.
The button triggers the automation successfully
I then want the page to reload after the automation is finished (maybe even have a way to show the user that the automation is still running, eg. a loading-screen, then I try to reload the page after the automation is finished.

It works, if i use this method: I want my Webhook response to redirect to my softr page - #7 by LuisaMarie

→ the webhook response sends the page, but it only seems to work, if the automation is finished before the softr success message, if it takes longer, it does nothing, no redirect.

I works well with this method in forms: Redirect via Webhook After Form Submission

but i can’t get it working for the button. What do i do wrong? Do I need a similar custom code like in the form submission tutorial? I don’t know how to change the code though :-/

Thanks!!!

Best,
Amir

Hello @Amir1,

If I get correct then you need this custom code > Refresh dynamic block after Call API action

Hi @Suzie , thanks for your answer!! No, it didn’t work unfortunately, maybe i do something wrong. I’ve tried this code:

This is the webhook response:

the problem seems to be that in the form, it waits for the response, but in the button it doesn’t wait, i get the “api call success” message, and then nothing happens, no redirect.

I’m no programmer, so I don’t really understand the code :-/

I’ve tried this code

<script> 
// Code for the button click (list-details4)
    window.addEventListener('load', () => {
        const button = document.getElementById('list-details4');
        if (button) {
            button.addEventListener('click', () => {
                window.addEventListener('call-api-success-list-details4', (e) => {
                    const response = e.detail.response || {};
                    const data = response.data;
                    if (data && data.redirect) {
                        window.location.href = data.redirect;
                    }
                });
            });
        } else {
            console.error('Button with ID "list-details4" not found.');
        }
    });
</script>