allen
allen11mo ago

SendGrid Example?

I am trying the most basic SendGrid implementation in an action (which works fine in regular NodeJs env), but getting the following error, even though I'm not using SendGrids template substitutions. Uncaught TypeError: Cannot read properties of undefined (reading 'substitutionWrappers') The code is as follows:
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
await sgMail.send({
to,
subject,
from,
text,
});
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
await sgMail.send({
to,
subject,
from,
text,
});
Anyone have success integrating SendGrid in Convex?
5 Replies
ian
ian11mo ago
have you tried putting @sendgrid/mail into external packages in convex.json? maybe it's something in the way it's bundling
allen
allenOP11mo ago
I haven't. I'll check the docs around that -- havent come across needing to use external packages yet. That seemed to work Is there a complete spec for convex.json? For example, I'd love to be able to change where it sources my schema from, rather than schema.ts
Indy
Indy11mo ago
Though we have some forward looking internal ideas around this, it is currently a fairly limited set of functionality. Basically just the external packages stuff and where you want your convex folder to be (https://docs.convex.dev/production/project-configuration#changing-the-convex-folder-name-or-location)
allen
allenOP11mo ago
Ha yeah I came across that but was hoping for something more. It also doesnt mention the exclude functionality there, so wasnt sure if that page was meant to be the complete spec for the json.
Indy
Indy11mo ago
It isn't. But I agree, we should have a full reference guide written down somewhere. @ballingt had started formalizing some of this. I'll put it on our internal list.

Did you find this page helpful?