If you want your users to be able to reply to transactional emails and get their replies into your platform (e.g. as a message, etc.) you can use Postmark’s Emailing API to set up inbound parse.
Before using Postmark, I tried Sendgrid’s inbound parse and researched a variety of options, but decided to go with Postmark due to great pricing, great documentation and a good parser engine that cuts old email threads automatically before posting the content to your app’s endpoint.
Here it goes:
1) Sign up for Postmark and setup a new server. Call it “inbound parser” or whatever you want to name it.
2) Create a new backend workflow in your app. This should be a public endpoint. Check the setting below. Call it whatever you want.
3) Go to Settings / API and copy your apps public endpoint link.
4) Go back to your workflow, click “Detect Data”
5) Go to your server’s settings page in Postmark and paste the public endpoint link into the webhook field. Click “Check” (make sure your app is waiting for the call aka the “Detecting Request Data” dialogue is open). Postmark will now do a test call to the public endpoint in your app. If it worked out, it will return with a status code of 200. Click “Save Changes”
6) Back in your app, you will now see the Request Data overview dialogue. Click “Save”. Awesome! You just setup inbound parse into your app.
7) You can now send emails to Postmark’s inbound email address to test your connection (find it on your servers settings page). Any email sent to this address will be posted to your endpoint. You should set up inbound domain forwarding in Postmark. I won’t explain this, as it’s documented very well within Postmark.
8) Now you can do all sorts of fun stuff in the app with the data from Postmark, e.g. create messages, etc.
Things to consider:
A) I recommend to set up an “intermediary” data type, that saves the most important info from the call your endpoint receives. Different email engines send data in different formats to Postmarks, so e.g. “Stripped Text Reply” might not always work. You could call this “Parse_Data” and save things like the inbound emails from, to, html reply body, stripped text reply body, text body, etc. This is important to not loose data, when something goes wrong.
B) It’s possible to take attachments from incoming emails and save them in the app. I will explain how to do this below.
C) To make sure incoming emails are routed to the right user, conversation, whatever you want to use the data for, you should assign individual keys to each user, message stream, etc. in your app and set them as the reply_to address when you send outbound emails for conversational transactional emails.
We solved by setting outbound email reply_to email addresses as INDIVIDUALKEYUSER12DIGITS_INDIVIDUALKEYANOTHERTHING12DIGITS@yourappdomain.com (e.g. [email protected]).
When a user replies to an email, the app will cut the reply_to information from the Postmark call using find&replace and truncated_to and do a search for the right user and message stream.
Bonus: create files from inbound email attachments
1) Create a new datatype. I call this “parsefile”. “message” is the message in my database (another datatype) that I want to attach the files to.
2) Create a new backend workflow. I call this “create_attachments”
3) This is the workflow (in the right order) that I set up to create attachments. You will need the plugin “EZ Uploader” to decode the Base64 attachments.
Step 1) Create a new “parsefiles”
Step 2) Decode the base64 string attachment using the EZ Uploader plugin
Step 3) Use the newly created file and attach it to whatever you want (e.g. a message). The file can be accessed like this
Step 4) Add a step in your inbound parse workflow where you schedule this backend workflow on the list “Request Data’s attachments” (which is a basically a list base64 encoded strings which are your attachments)
Feel free to ask questions! Hope this helps