Hi! I want to send an email to the customers that register for the first time. I figured it shouldn't be too hard since Medusa already offers the event customer.created (https://docs.medusajs.com/development/events/events-list#customer-events)
So I wanted to ask if my plan is correct:
- create a new subscribe that listens to the event
customer.createdin the/src/subscribersdirectory of the backend repo. - send email via the sendgrid plugin when the event is triggered
It made sense to me, so I went and created this class in /src/subscribers/customerCreatedNotifier.ts
import { Customer } from "@medusajs/medusa"
/**
* https://docs.medusajs.com/development/events/events-list#customer-events
* customer.created event
*/
class CustomerCreatedNotifierSubscriber {
constructor({ eventBusService }) {
eventBusService.subscribe("customer.created", this.handleCustomerCreated)
}
handleCustomerCreated = async (customerData: Customer) => {
//TODO: send email via sendgrid plugin
}
}
export default CustomerCreatedNotifierSubscriber;
But now I'm stuck... I can't really figure out how to send the mail using the sendgrid plugin, since there is very little documentation on it (https://www.npmjs.com/package/medusa-plugin-sendgrid)
Does someone know how to do it? Thanks in advance!
SendGrid transactional emails. Latest version: 1.3.7, last published: 2 months ago. Start using medusa-plugin-sendgrid in your project by running npm i medusa-plugin-sendgrid. There are no other projects in the npm registry using medusa-plugin-sendgrid.