Our block of code (referenced below) is returning a " contactId does not match current session contact" and emails are not sent to the inputed emails on our live Wix site. The only way we have been able to make this code work is by clearing cache ahead of inputing emails on the live site, which is impractical in a real life scenario as users will not know that there is a bug and suggests that the identity of the current user is the root of the problem. Ideally, an email should be sent to the inputed email on every button action regardless of the current user’s identity and even on repeat actions (e.g. if an email is sent to a user’s email input and the user proceeds to repeat the same action with a different or identical email there should be two emails sent every time)
We would like to send emails through Wix without using a 3rd party option given the provided Wix APIs. Wix automations will not work in our case as there are instances where we would like to send two emails simultaneously and we are not collecting data through forms. Could you please recommend a block of code that will successfully send triggered emails using the required Wix API given the inputs in the code below. We are sure there are a multitude of Wix sites that are accomplishing this.
Active Inputs (seen below)
input1 = user’s inputed email
join_waitlist_click = button action
welcome_email = triggered email format
Inactive Inputs
general_waitlist = database
inputed_email = email database field
*provided if needed in recommended code
Current Syntax
import wixCRM from 'wix-crm';
$w.onReady(function () {
console.log("made it to onReady")
});
export function join_waitlist_click(event) {
console.log("made it to join_waitlist_click")
wixCRM.createContact({
"emails": [$w("#input1").value],
})
.then((contactId) => {
console.log(contactId)
wixCRM.emailContact('welcome_email', contactId);
})
.then(() => {
console.log('email sent')
})
.catch((err) => {
console.log(err);
});
}
#triggeredemails #WixAPIs