Hi folks, I’ve had a function working like a charm, sending an email using the wix-crm-backend emailContact method.
A few days ago, this suddenly stopped. And I can’t figure out why. My initial thought was I missed a few promises, and yes I actually did (why did it work before??) then tried, some error messages disappear. But yet no email.
The error message I keep getting is the following:
https://<my-wix-site-URL>//_api/wix-code-public-dispatcher/siteview/backend/triggerNewMission.jsw/alertNewMission.ajax?gridAppId=a4183198-61c8-4d97-893a-044960c86aee&instance=wixcode-pub.649251419b6ba09059ed536ccc2d1c6b9c323ed4.eyJpbnN0YW5jZUlkIjoiZWE1MGEyZmYtODRiZS00ZmRlLTg4NWQtYmY3NzRjZjQxMWY1IiwiaHRtbFNpdGVJZCI6IjQwMWJhZmQ5LTQ5NGEtNDc0MS04OTY0LTQ0ODM3NDM2YjFlNSIsInVpZCI6IjE5NTZhNmZhLTIzNTctNDE2MC1hOTJmLWE2YmNjMTMzYTVkYSIsInBlcm1pc3Npb25zIjoiT1dORVIiLCJpc1RlbXBsYXRlIjpmYWxzZSwic2lnbkRhdGUiOjE1ODg4ODg4MDM2ODUsImFpZCI6ImJkMWIxODI3LTQ3MDktNGQ3Ny04N2U1LTVlOTM4MWIyNGI3NyIsImFwcERlZklkIjoiQ2xvdWRTaXRlRXh0ZW5zaW9uIiwiaXNBZG1pbiI6dHJ1ZSwibWV0YVNpdGVJZCI6IjAyMmRiYTMwLTA3OTUtNDRiMi04M2I0LWM3ZWU4NWEwYzFiYyIsImNhY2hlIjpudWxsLCJleHBpcmF0aW9uRGF0ZSI6IjIwMjAtMDUtMDhUMDI6MDA6MDMuNjg1WiIsInByZW1pdW1Bc3NldHMiOiJIYXNEb21haW4sU2hvd1dpeFdoaWxlTG9hZGluZyxBZHNGcmVlIiwidGVuYW50IjpudWxsLCJzaXRlT3duZXJJZCI6IjE5NTZhNmZhLTIzNTctNDE2MC1hOTJmLWE2YmNjMTMzYTVkYSIsImluc3RhbmNlVHlwZSI6InB1YiIsInNpdGVNZW1iZXJJZCI6IjE5NTZhNmZhLTIzNTctNDE2MC1hOTJmLWE2YmNjMTMzYTVkYSJ9&viewMode=site
[Error] Failed to load resource: the server responded with a status of 429 () (alertNewMission.ajax, line 0)
The function itself is in a file in the backend and declared as follow:
// Filename: backend/triggerNewMission.jsw (web modules need to have a .jsw extension)
import wixData from 'wix-data';
import { hookItUpBaby } from 'backend/hookSlack.jsw';
import { sendNewMission } from 'backend/notifications.jsw';
import { sendSMS } from 'backend/sendSMS.jsw';
import { translatedLabels, translatedEmails } from 'public/translater';
export async function alertNewMission(missionId) {
// get mission's coordinates, type, lang from Askers collection
Interestingly, in the same function, there is an SMS alert system which is triggered and works like a charm, and a hook to a slack bot which also works like a charm.
But this piece of code does not work at all…
sendNewMission(translatedEmails["NewMission"][helpers.items[i].mainLang], helpers.items[i].userId, {
variables: {
askType: translatedLabels[ask.items[0].askType][helpers.items[i].mainLang],
helpeeFirstName: missionDetails.items[0].firstName + " " + missionDetails.items[0].lastName.substr(0, 1),
helpeeLocation: missionDetails.items[0].postcode + " " + missionDetails.items[0].city + ", " + missionDetails.items[0].country,
helpeeDistance: "N/A"
}
});
which is calling a function stored in backend/notifications.jsw
// Filename: backend/notifications.jsw (web modules need to have a .jsw extension)
import wixCrm from 'wix-crm-backend';
export function sendNewMission(emailID, contactId, message) {
wixCrm.emailContact(emailID, contactId, message)
.then(() => {
// email has been sent
return true;
})
.catch((err) => {
return false;
});
}
I’m getting clueless as to why it does not trigger the triggered email… has any changes been done to the wix-crm-backend to limit when emails can be sent (similarly to wix-crm which can only trigger emails for new contacts or logged in members)?
Any advise much welcome!