For todays post I wanted to explore a use case for the SendGrid API, that I personally don’t see too often. That use case is mashing up a Machine Translation API with our mail API and webhook. I want to create an email address that lets me communicate with my coworkers and friends that I have been lucky to make in Brazil.
How this will work:
I’m going to create an application that will translate any email that I send out into portuguese. Any email that gets sent to that address will be translated back into english. The concept is pretty simple and our API makes this type of communication really easy.
- SendGrid Account (www.sendgrid.com/free)
- Translation API (I’m using the Google Translate Python module, https://github.com/terryyin/google-translate-python)
Just like we did in the last Code Challenge post with Orchestrate, I’m going to use our parse webhook and create a domain name for receiving incoming mail.
I’m going to use: brazil.bymail.in , this means any email sent to email@example.com will be sent to my Python application.
Here is the code:
This code is just for sample use. It will take any email it gets, translate it into Portuguese and email the translated content back to the sender. This is pretty simple, fun and powerful. I’ve posted some photos that showcase the translation:
Over the next few weeks, I’m going to continue writing about different technologies, so check back every Monday, Wednesday, and Friday for new tech posts! You can also visit my intro post that will have an updated list of everything I’ve written.