inbound

command
v3.5.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2019 License: MIT Imports: 12 Imported by: 0

README

This helper is a stand alone module to help get you started consuming and processing Inbound Parse data.

Table of Contents

Quick Start for Local Testing with Sample Data

git clone https://github.com/sendgrid/sendgrid-go.git
cd sendgrid-go

Run the Inbound Parse listener in your terminal:

cd helpers/inbound/
go run inbound.go

In another terminal, run the test data sender:

cd [path to sendgrid-go/helpers/inbound]
go run inbound.go ./sample_data/default_data.txt http://127.0.0.1:8000/inbound

More sample data can be found here.

View the results in the first terminal.

Quick Start for Local Testing with Real Data

Setup your MX records. Depending on your domain name host, you may need to wait up to 48 hours for the settings to propagate.

Run the Inbound Parse listener in your terminal:

git clone https://github.com/sendgrid/sendgrid-go.git
go run inbound.go

In another terminal, use ngrok to allow external access to your machine:

ngrok http 8000

Update your Twilio SendGrid Incoming Parse settings: Settings Page | Docs

  • For the HOSTNAME field, use the domain that you changed the MX records (e.g. inbound.yourdomain.com)
  • For the URL field, use the URL generated by ngrok + /inbound, e.g http://XXXXXXX.ngrok.io/inbound

Next, send an email to [anything]@inbound.yourdomain.com, then look at the terminal where you started the Inbound Parse listener.

Deploy to Heroku

Get a Heroku account.

Deploy

Setup your MX records. Depending on your domain name host, you may need to wait up to 48 hours for the settings to propagate.

Update your Twilio SendGrid Incoming Parse settings: Settings Page | Docs

  • For the HOSTNAME field, use the domain that you changed the MX records (e.g. inbound.yourdomain.com)
  • For the URL field, use the URL generated by Heroku + /inbound, e.g https://[name-of-your-app].herokuapp.com/inbound

Next, send an email to [anything]@inbound.yourdomain.com, then look at your Heroku logs: https://dashboard.heroku.com/apps/[name-of-your-app]/logs

While you are waiting for your MX records to propagate, you can test by using the test data sender:

git clone https://github.com/sendgrid/sendgrid-go.git
cd sendgrid-go
go build
./sendgrid-go ./helpers/inbound/sample_data/default_data.txt https://[name-of-your-app].herokuapp.com/inbound

To make changes: clone, modify and push the changes. Heroku CLI is required.

For example:

git clone [repo url]
git checkout heroku-deployment
heroku git:remote -a [name-of-your-app]
---make changes---
git add -A
git commit -m "updated configuration"
git push heroku heroku-deployment:master

Code Walkthrough

inbound.go

This module runs a net/http server, that by default (you can change those settings here, listens for POSTs on http://localhost:8000. When the server receives the POST, it parses and prints the key/value data.

conf.json

This file contains application environment variables (located in conf.json).

inbound.go & /sample_data

This module, in conjunction with the sample data, is also used to send sample test data. It is useful for testing and development, particularly while you wait for your MX records to propagate.

Testing the Source Code

Tests are located in the helpers/inbound folder:

Learn about testing this code here.

Contributing

If you would like to contribute to this project, please see our contributing guide. Thanks!

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL