Integrating SendGrid into an Application
Our sample application is an online educational platform written with the Django Python web framework. A PR was recently opened to integrate the SendGrid email API into the application, and in this tutorial we’re going to have Devin attempt its own SendGrid implementation to showcase how it can work with third party APIs.Initial Prompt
In our prompt, we provide some specific instructions about how and where we want Devin to integrate our SendGrid hooks, and we have Devin revert to an earlier commit hash before the above PR was merged, to give us a clean starting point for our integration. Follow along with the live Devin session here.

Implementing SendGrid
It then moves on to implementing the SendGrid API, and prompts us for our API credentials which we can set up as Secrets in Devin’s environment so that it may access them going forward as ENV variables.

- Devin configured SendGrid in a new email.py module rather than in the same file as the view itself. It also returns True or False to indicate whether the email sending was successful based on the SendGrid response code.
- Devin uses Python’s built-in logging module rather than print (which was a pattern that the PR reviewer specifically commented on).
- Devin also makes the From email configurable rather than hardcoded, but also adds a default value if the ENV var does not exist.
- Devin adds exception handling to its mailInstructor method.

Debugging
Devin quickly encounters an error, which is because I never provided it with a FROM address for my SendGrid account. Devin actually navigates in its Browser to the API docs to figure out what is going on here and understand the error messages and implementation best practices:


Adding Knowledge
Devin observes that my requests and implementation requirements may be generalizable, and prompts me to add Knowledge that it can utilize in the future:
Testing


