Automate User Email Integration with Brevo 'Conversations' Chat Box on Softr - custom code

Dear community,

I’ve worked on a piece of integration that I believe will be useful for many of us using the Brevo ‘Conversations’ chat box within our Softr web applications.

If you’ve been looking for a way to improve your users’ experience by eliminating the repetitive task of manually entering their email addresses when they use the chat box, this code is for you! With this integration, the user’s email address (if logged in) will be automatically passed to Brevo, streamlining the chat initiation process.

<!-- Brevo Conversations Integration with Softr -->
    (function(d, w, c) {
        w.BrevoConversationsID = 'YOUR_BREVO_ID_HERE'; // replace with your Brevo ID
        w[c] = w[c] || function() {
            (w[c].q = w[c].q || []).push(arguments);
        var s = d.createElement('script');
        s.async = true;
        s.src = '';
        if (d.head) d.head.appendChild(s);

        // Once the script is loaded, check for the user email and update integration data
        s.onload = function() {
            if(window.logged_in_user && window.logged_in_user['softr_user_email']) {
                BrevoConversations('updateIntegrationData', {
                    email: window.logged_in_user['softr_user_email']
                    // Add any other details you want here
    })(document, window, 'BrevoConversations');

Make sure to replace ‘YOUR_BREVO_ID_HERE’ with your actual Brevo ID.

I hope this proves helpful to some of you! Happy building! :sunflower: