Webhook trigger on User Login

Please specify a sub-category when posting your topic.

  • Get Answers for topics that you need help with

Is there a way to set a webhook triggered by a user login? I have been looking at Make, but that does not offer actions triggered by user logins out of the box.

Thank you.

Han

Hi @HanZuyderw85534

You can use JavaScript to trigger a webhook in Make.

function triggerWebhook(webhookUrl, data) {
    fetch(webhookUrl, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(data)
    })
    .then(response => {
        if (!response.ok) {
            throw new Error('Network response was not ok ' + response.statusText);
        }
        return response.json();
    })
    .then(data => {
        console.log('Success:', data);
    })
    .catch(error => {
        console.error('Error:', error);
    });
}

// Example usage:
const webhookUrl = 'https://example.com/webhook'; // Replace with your webhook URL
const data = {
    key1: 'value1',
    key2: 'value2'
};

triggerWebhook(webhookUrl, data);

You would need to call this function inside a knack-form-submit (see here for info about Knack events Form Submit) of your login view. You can send data to make by changing the key value pairs to info from knack, or not use data at all.

If you need further help please let me know.

Craig

Thank you Craig. It works. much appreciated!

1 Like