Reliasure Insurance Bot Trigger Rules

PHOTO EMBED

Wed May 08 2024 18:00:19 GMT+0000 (Coordinated Universal Time)

Saved by @nikanika4425

setTimeout(async () => {
    // Asynchronously fetch all necessary fields from Feathery
    const {
        bot_triggered,
        reliasure_age_group,
        reliasure_form_zip,
        reliasure_life_event,
        reliasure_insurance_use,
        reliasure_income,
        reliasure_gender,
        reliasure_dob_month,
        reliasure_dob_day,
        reliasure_dob_year,
        reliasure_fname,
        reliasure_lname,
        reliasure_street_address,
        reliasure_city,
        reliasure_state,
        reliasure_zip,
        reliasure_email,
        reliasure_phone,
        reliasure_aca,
        spiderscore,
        utm_source,
        zippopotamus_return,
        fbclid,
        good_lead,
        ipaddress,
        reliasure_edit_address,
        insurance_people,
        reliasure_apply,
        feathery_user_id,
        feathery_form_name
    } = await feathery.getFieldValues();

    if (bot_triggered === false) {
        const payload = {
            reliasure_age_group,
            reliasure_form_zip,
            reliasure_life_event,
            reliasure_insurance_use,
            reliasure_gender,
            reliasure_dob_month,
            reliasure_dob_day,
            reliasure_dob_year,
            reliasure_fname,
            reliasure_lname,
            reliasure_street_address,
            reliasure_city,
            reliasure_state,
            reliasure_zip,
            reliasure_email,
            reliasure_phone,
            reliasure_aca,
            spiderscore,
            utm_source,
            zippopotamus_return,
            fbclid,
            good_lead,
            ipaddress,
            reliasure_edit_address,
            insurance_people,
            reliasure_apply,
            feathery_user_id,
            feathery_form_name
        };

        // Update bot_triggered to true in Feathery to indicate the bot has been triggered
         feathery.setFieldValues({ bot_triggered: true });
        console.log("Triggering bot and setting bot_triggered to true");

        // Function to load URL in a hidden iframe
        const loadUrlInHiddenIframe = () => {
            const refValue = `WebsiteTraffic--${reliasure_fname}--770490--${reliasure_fname}--984184--${reliasure_lname}--658292--${reliasure_email}--578105--${reliasure_phone}--372998--${reliasure_aca}`;
            const iframeUrl = `https://app.strikedm.com/webchat/?p=1325191&ref=${refValue}`;

            const iframe = document.createElement('iframe');
            iframe.style.cssText = "width:0; height:0; border:0; opacity:0; position:absolute;";
            iframe.src = iframeUrl;

            document.body.appendChild(iframe);

            // Cleanup after 5 seconds
            setTimeout(() => document.body.removeChild(iframe), 5000);
        };

        // Call the function to load URL in hidden iframe
        loadUrlInHiddenIframe();
    } else {
        console.log("Bot has already been triggered");
    }
}, 5000); // Delay set for 5 seconds
content_copyCOPY