SendGrid Inbound Parse

Hello :slight_smile:

Is anyone familiar with setting up the Inbound Parse with SendGrid into Bubble?

SendGrid states this is accomplished through a webhook. I’ve been trying to follow these docs, which describe adding a new MX record, setting up an API endpoint in Bubble, and pasting that public endpoint into Sendgrid “where the parse data will be POSTed”.

I think that I also need to use the API connector to set up API calls for sending the emails that should be parsed if they’re replied to (though I’m not sure…?)

If anyone can point me in the right direction, that would be greatly appreciated. Thank you so much!

It looks fairly straightforward. I recently did a very similar setup using Postmark. Which parts are you having issues with?

Hi @nnich19 :slight_smile: Thank you so much for your reply.

I’ve added the correct MX record to my domain as follows:

Then it states that I need to “Point to a Hostname and URL”. The docs state:

There I’ve set that receiving domain to be parse.(mydomain).com, and set the destination URL to be my API endpoint in my Bubble app in this format:

The docs then state to test that everything is working by sending an email:

I tried sending an email to “test@parse.(mydomain).com”. When I did that, the API workflow was not run, so I’m assuming I’m missing something but I’m not sure where?

Hm… Really tough to tell without being able to actually get in there and troubleshoot. Are you getting any bounce messages when you send the email (domain doesn’t exist, etc.)? If so, the subdomain may not be set up correctly with whoever your provider is.

What I ended up doing was creating the subdomain with the provider (I was using Digital Ocean) and just putting the MX record in there; so rather than put the MX record on “[mydomain].com”, I put it on “parse.[mydomain].com” and just put “@” as the hostname (rather than “parse”).

Hope that made sense…

I couldn’t get it to work so i went with a different service that works great and was easy to set up.

(My apologies for so many edits!)

@nnich19 It’s working now! :smiley: I’m still not sure why the POST call wasn’t running before, but then it began to. Then I used “Detect Request Data” for the parameter definition. It seemed like nothing was happening there, but it just took a minute for the parameters window to show up in Bubble. Now everything is being brought into Bubble as expected! Thank you so much for pointing me in the right direction.

My goal with this endpoint is to create a new Message (which is now working) in the first action, and then add that Message to a specific Thread thing. Do you know where I should put that Thread’s unique ID, in order to make sure the correct Thread is being modified in Bubble once the new Message email is parsed?

@gnelson Which service are you using instead now?

Alright :slight_smile: I put the unique ID of the Thread as the reply-to email Username. So when a User is sent an email, the “reply-to” address is [Thread’s UniqueID]

After the User replies via email, the POST API call creates a new Message in the first action. The second action extracts the Thread’s unique ID from the reply-to email address using regex, and adds the new Message created in the first action, to that Thread’s list of Messages.

The only trouble now is that the Message’s text is what the User replied to in the email, as well as the quoted text from the email they are replying to. Is regex the way to go here as well? :thinking:

Will this work for messages sent from a particular page or will this affect all messages? I ask because on the other pages I am not allowing users to communicate off the App/platform until the transaction is finalized. I want to do this for messages sent from a specific page on my App (allowing users to reply directly through email).

@Sheila123 Yes that is possible! :slight_smile: On the page where you will allow Users to reply via email, you would specify in the “Send Email” action that the User can reply. Then, make sure the “reply to” email address alias contains the unique ID of the thing that the User can reply to (such as the Thread’s unique id), a + sign, and that Users unique ID – so it becomes:

Then you can use/lookup those unique IDs in Bubble using regex. One way to get the Thread’s unique ID from the reply-to email address would be to use the regex pattern:

That will give you everything before the “+” sign of the reply-to email address.

To get the part between the “+” sign and the “@” sign, you can use the regex pattern:
Then, add a “:find and replace” to that expression to remove the + sign from the regex result, and another “find and replace” to remove the @ sign from the regex result. My apologies, I’m not sure if this is the best approach but I couldn’t find a regex pattern which pulled the part of the alias between the + and @ sign of the reply-to address. If anyone knows of a better way to do this, please let me know! :slight_smile:


Wow. Thanks for all your help. You are awesome!

1 Like

Do you mind sharing how you have your API workflow setup? I seem to be doing something off. Thanks again.

@Sheila123 I actually don’t have this setup anymore but I think I can remember how I set it up originally :slight_smile: Have you already set up the webhook in your SendGrid account with the Bubble API endpoint? Or that’s the part that isn’t working yet?

@fayewatson So far I have

  1. Set up the Inbound Parse in Sendgrid as per the following:

  1. Setup the MX in my DNS as per the following:

  1. I setup the Endpoint in Bubble API as per the following:

But when I setup the workflows for the API (create message, add to conversation) I am not sure how to pull the data in.

Ok great! :slight_smile: For the Bubble API endpoint, did you click “Detect data” and did it run successfully? I think if it has run successfully, the “Modify Types” button should be enabled. I remember this can take a minute or two for the response data to show up:

Once the data is detected successfully, you’ll be able to use “Request data's body's text”, in your Create a New Message action to save that as the new Message’s text field.

And you can use “Request data's body's to:extracted with Regex” to obtain either the unique ID of the Thread from the reply-to address or the unique ID of the User from the reply-to address. Let me know if the Detect Data doesn’t work, I know that was definitely the trickiest part!

1 Like

@fayewatson. Thanks a lot for your help!!! I hope it works. :slight_smile:

@Sheila123 My pleasure!! :slight_smile: Let me know if it doesn’t!

@fayewatson - I’m glad to see this thread surfaced. Figuring out SendGrid’s inbound parse has been on my wish list of things to experiment with for a while. Should be much easier with your insights here. :slight_smile:

1 Like

Thank you @dan1! :slight_smile: So glad to hear it was helpful! I have been meaning to try Zapier’s email parser to see if that would work as well (since it may be easier to setup!). The video looks interesting but I’m not sure if it works with SendGrid. Will report back if it does!


I am new to bubble and looking to build an app which can handle replies, I think relying on message Id while sending is more robust?

Also can I ask someone from this forum to help me out with this integration?

Can you set this up as a support/helpdesk type system? Once an email comes in it sends an automatic reply notifying the user that a support request has been created, then from the bubble interface be able to reply to reply to that email, have the user reply again, etc…

1 Like