Send a transactional email through SendGrid dynamic templates.
### How this function works
The function will be triggered by a Pub/Sub event published with the specific topic `SEND_SENDGRID_TRANSACTIONAL_EMAIL`. The message should contain the email address of the person and the data will be used during the generation of the email.
### Prerequisites
* You must have previous knowledge of **SendGrid**.
### Function details
Here is an example of how to use the function when it is installed:
```js
const dataBuffer = Buffer.from(JSON.stringify({
to: 'customer@mail.com',
data: {
customerName: 'John Snow',
purchasedFunctionName: 'sendTransactionalEmail',
purchasedAt: new Date(2021, 4, 1, 10, 0, 0).toString(),
},
templateId: 'functionPurchasedTemplateId'
}));
await pubsub.topic('SEND_SENDGRID_TRANSACTIONAL_EMAIL').publish(dataBuffer);
```
So, the email will be sent according to the template specified by the templateId. For example, if the template is:
```
Dear , the function was purchased successfully at .
```
the sended email will be the following:
```
Dear John Snow, the function sendTransactionalEmail was purchased successfully at Sat May 01 2021 10:00:00.
```
### Resources
For more information about SendGrid, see:
+ [SendGrid Support](https://support.sendgrid.com/hc/en-us)
+ [SendGrid Sending email](https://sendgrid.com/docs/ui/sending-email/)