In this guide you’ll learn how to send Moesif behavioral emails with Sendgrid.
Moesif behavioral emails is a feature that automatically sends emails to customers based on their API usage. This can be used to notify customers about technical issues, such as hitting rate limits, using deprecated APIs, or broken integrations. You can even use it to trigger business-related events such as when an item is shipped. If something can be mapped to an API call, then you can send an email from it.
In a companion article, we covered how to configure behavioral emails within your Moesif dashboard.
Sendgrid is a managed email service. They offer an API to send emails to your users and host SMTP servers for you.
Setting up an Email Server
The first step in setting up the email server is getting the SMTP credentials from Sendgrid.
For this, you have to log into the Sendgrid dashboard.
The following screenshot illustrates how you navigate to the credentials.
This will start a guide that will lead you through the Sendgrid API key creation, give you the SMTP credentials, and also test that everything works as expected.
The API key needs a name to be created. The generated API key will be your SMTP password.
These credentials have to be entered into the Moesif email server configuration form.
To navigate to the form, follow the steps in the next screenshot.
You can copy and paste the credentials from the Sendgrid site to the Moesif site.
If you have problems with the SSL port, you can used port 587.
The Moesif form looks like this:
Track the end to end customer journey with MoesifLearn More
Testing the Setup
You can then send an example email via the freshly configured SMTP server with Moesif.
After you’ve configured the mailserver, you have to create a new email template:
For the new template, you have to fill out the required fields: template name, subject line and from email address.
Press verify integration in the Sendgrid console and Sendgrid will wait for you to send a test email.
After that click the “Test” button in the Moesif site and enter the target email.
The Sendgrid console will then confirm that the SMTP connection worked.
Setting up Moesif behavioral emails with Sendgrid only takes a few minutes.
Using a service like Sendgrid alleviates many common problems that might occur when sending email, such as validation issues and email being incorrectly identified as spam.
By combining Moesif’s behavioral email service with Sendgrid, you’re able to keep your API consumers abreast of important issues.