Cómo hacer del correo electrónico una parte poderosa de su aplicación web -

PorGeoffrey Craig es

SendGrid Parse Webhook es una herramienta poderosa con muchos casos de uso . Una vez configurado, todo el correo electrónico entrante de un dominio o subdominio se dirige a su aplicación. Lo que puedes hacer es infinito, pero puede ser un poco complicado así mismo si es la primera vez.

Brindar a sus clientes una forma de acceder a su aplicación desde su cuenta de correo electrónico es una forma importante de impulsar su actividad y participación en su sitio web.

Una de mis herramientas de productividad populares favoritas, iDoneThis , me brinda una forma sencilla de registrar y compartir las tareas que completa cada día con mis compañeros de equipo. Todos los días, iDoneThis me envía un correo electrónico preguntándome qué completo hoy. Desde mi cuenta de correo electrónico, puedo responder fácilmente con mis tareas completadas sin tener que iniciar sesión en el sitio web. Curiosamente, la mayoría de mis compañeros de equipo completan la mayoría de las actualizaciones de su sitio web respondiendo por correo electrónico.

También puede crear la misma funcionalidad poderosa al comentar, recibir contenido por correo electrónico y permitir respuestas para crear, continuar y resolver tickets de soporte. Con Inbound Parse Webhook , el servicio SMTP de SendGrid , puede hacer que sus aplicaciones sean interactivas invitando respuestas y respondiendo a los usuarios a través de su correo electrónico.

SendGrid Parse Webhook le permite analizar el contenido del correo electrónico y los archivos adjuntos de cualquier correo electrónico entrante y publicar los datos a través de JSON en su aplicación. La capacidad le permite lograr lo siguiente, desde respuestas de correo electrónico hasta la aplicación de su sitio web:

  • Publicar entradas de blog
  • Utilice respuestas por correo electrónico para actualizar su lista de correo o base de datos.
  • Sube fotos y vídeos
  • Iniciar y resolver solicitudes de tickets de soporte
Índice de contenidos
  1. empezando
    1. 1. Comience clonando este repositorio de Github y cd en su directorio.
    2. 2. Configure sus credenciales.
    3. 3. Cambie el contenido de .env a su nombre de usuario y contraseña de SendGrid.
    4. 4. Ejecute la aplicación.
    5. 5. Use a local tunnel like ngrok to test locally and quickly – rather than deploying code to a live server.
    6. 6. Set up SendGrid and MX Records. It can take up to 48 hours.
    7. 7. Send an email from your personal email account.
    8. 8. Test and play with the API.
    9. 9. Customize your parser.
    10. About Geoffrey Craig

empezando

Las instrucciones a continuación son para poner en funcionamiento localmente el Webhook de análisis entrante.

1. Comience clonando este repositorio de Github y cd en su directorio.

$ git clon https://github.com/scottmotte/sendgrid-parse-api-example.git$ cd sendgrid-parse-api-example

2. Configure sus credenciales.

$ mv .env.ejemplo .env

3. Cambie el contenido de .env a su nombre de usuario y contraseña de SendGrid.

SENDGRID_USERNAME = tu_sendgrid_nombre de usuarioSENDGRID_PASSWORD = tu_sendgrid_contraseña

4. Ejecute la aplicación.

$ npm instalar $ nodo app.js

Si npm install no funciona para usted, puede intentar instalar a través de MacPorts :

$ sudo puerto npm instalar

Si recibe errores que indican que falta un módulo, esto significa que debe instalarlo. Por ejemplo, la instalación de dotenv resuelve el problema de instalación de app.js al no poder crear una instancia de la variable dotenv.

$ npm instala dotenv

5. Use a local tunnel like ngrok to test locally and quickly – rather than deploying code to a live server.

Ngrok allows you to securely expose a local web server to the web and capture traffic for detailed inspection and replay.

Download, unzip, and start the ngrok process. After you start the process, ngrok will give you a unique URL for you to inspect locally on.

The instructions below are for getting ngrok to work locally on a Mac. Click here to install a local setup for other operating systems.

$ wget https://dl.ngrok.com/darwin_amd64/ngrok.zip$ unzip ngrok.zip -d /usr/local/bin$ ngrok 3000

6. Set up SendGrid and MX Records. It can take up to 48 hours.

Here is how you can get up and running as soon as possible. Once your MX records have fully propagated, you can send emails on production in up to 48 hours.

First, you can set up your SendGrid Parsing Incoming Emails setting (you must have a provisioned SendGrid account to access this link). Click on the “Developers” tab for the “Parsing Incoming Emails” link. In the Hostname field, specify your hostname (i.e. yourdomain.com) that you would like. In the Url field, input the unique URL that ngrok provided you.

Please configure an MX record on the hostname you set above to point to mx.sendgrid.net. It should look something like the following.

Within 2 days, your MX records will completely propagate.

7. Send an email from your personal email account.

If you send an email to [email protected], in a few minutes, the app you have running will parse and deliver the contents to you in JSON format.

8. Test and play with the API.

Congratulations, you have set up a simple way to parse your emails efficiently!

Now, you are ready to explore and make calls to the API.

Inspecting the payload contents:

If you just need a quick way to inspect the payload contents of the Parse Webhook, you can use RequestBin, a free tool, after setting up your MX records.

Posting from the command line:

If you’d like to get your hands dirty from the command line, you can try SendGrid’s free webhook debugger tool, which is a fast way to start seeing how events appear.

At the heart of the tool is a URL that you can set as your Parse Webhook endpoint. Each time you load the URL, you will get a unique ID within the URL.

Below are two examples to get started with your webhook. The GET example will begin listening for new data.

From your command-line terminal, paste in the following GET example:

$ curl -X GET  http://hookdebug.sendgrid.com/v1/events/e6a20fffc9c1968dd64684f0b11b9c29

To paste in whether your Parse Webhook is receiving data, type in the curl command from the POST example into a second terminal screen:

$ curl -X POST   -d "foo=bar"   -d "alice=bob"   http://hookdebug.sendgrid.com/v1/events/e6a20fffc9c1968dd64684f0b11b9c29

The response on your terminal window should now have new content:

{"event_id": "e6a20fffc9c1968dd64684f0b11b9c29"}

Next, send an email to the domain or sub-domain that you are using for inbound parsing. Within a few minutes, you should see the parsed email as JSON in your terminal window.

9. Customize your parser.

As you can see, the details of email data separation and routing an incoming message to the SendGrid script are done behind the scenes for you. Starting with a blank slate, you can use the Parse Webhook creatively, however you wish.

Now you’re ready to place some real email data through that webhook! The instructions below are for getting the Inbound Parse Webhook up and running locally on a Mac. Click here to install a local setup for other operating systems.

To customize how you’d like to parse your emails, you can start to customize the code in routes/inbound.js.

For example, you can rewrite the inbound.js file to complete an action if the email contents contain a word, or even store attachments in a way that would suit your application and database.

For use cases, case studies and examples, please click here to download the Parse Webhook Guide or check out the Parse Webhook API library. When looking at the Parse Webhook examples, you will notice that the two most common ways it is used are: interacting with your users and collecting data within your applications via email. With the webhook, you can develop features that make frequent tasks more productive for your users without having them leave their email inbox. Collecting insights and making your emails interactive have never been easier.

About Geoffrey Craig

I am a programming polyglot, writer, and software engineer. I also like games, math, and genuinely (non-GP) free software.

www.sendgrid.comSendGridPosts

Te podría interesar...

Deja una respuesta

Subir