I am trying to send a triggered email from the onOrderPaid event in the events.js file. I keep getting the following error:
Error loading web module backend/events.js: Cannot find module 'wix-crm'
Require stack:
- /user-code/backend/events.js
- /user-code/stubmodule-that-does-the-require.js
- /elementory/node_modules/scoped-require/index.js
- /elementory/factories.js
- /elementory/create-app.js
- /elementory/cloud-grid-runner.js
which originates from this line:
import { triggeredEmails } from 'wix-crm';
I have tried making a public code file called emailtouser.js which contains just the code for sending a triggered email in hopes of getting around this error. This is the code in emailtouser.js file:
import { triggeredEmails } from 'wix-crm';
export function sendemail(license, contactid) {
triggeredEmails.emailContact('licenseEmail', contactid, {
variables: {
licenseKey: license
}
});
}
However I still keep getting the exact same error whenever this line is ran from the events.js file:
import {sendemail} from 'public/emailtouser.js';
How do I send a triggered email from the onOrderPaid event in the events.js file without getting this error?