Skip to main content

Ok, on my website (I'm using Webflow and their forms), I have a newsletter opt-in. I am using Intercom to manage all of this, so then I need to use Zapier to connect the two.

 

The only option I get in Zapier around email subscription is "Unsubscribed From Emails", which I mark as False. The only thing is, I have an "Opt-in" subscription type, and Intercom doesn't auto-add this type, only the opt-out ones.

 

Is there any way to Opt-in to these without physically going into each contact and clicking the box?

So at the moment Zapier is limited by what is available within the Intercom API, and then within that what they choose to implement (there are many things you can do with the API that are not in Zapier).

However, fortunately Zapier does have a webhook/api model which will allow you to send API commands which will greatly extend your capabilities to automate things with Intercom. (might depend on your plan).

 

If you're new to making API commands I promise it's not too tricky, kinda like riding a bicycle once you understand them fundamentally it's easy to figure it out for all apps.

 

So right now, Intercoms API is on version 2.5 and the Attach a Contact request under the Subscription model only supports the opt_out functionality right now.

imageHowever, the Unstable v0 API does support opt_in:

 

image 

If you create a new app within the developer portal you can change the API to any version, and you can select v0.

 

You can then use the List all Subscription Types request to find the IDs of all the subscriptions you have, and then get the ID for the one you want. From there you can use the Attach a Contact request in an API request within Zapier to perform this step instead.

 

If you're not familiar with making API requests I'm happy to provide some more detail and steps on how to achieve this, only thing I'd get you to check though is if your Zapier plan allows you to have the webhooks step, as that'd be crucial to achieving this in Zapier. I'm not sure if it's a premium step or not.

 

Hope that helps!

 


Wow thanks Zak! Yes I can do a webhook connection, but am not clear on how I achieve this, even after looking at the unstable v0 documentation.


No problem 🙂

 

Oh excellent. No problem, it's not necessarily that clear initially, but like I said once you get the fundamental understanding of APIs it becomes a lot easier.

I'll put together a little guide for you on how to achieve this; would you be able to though share a screenshot of how your Zap is currently set up so I can get a clearer idea on the flow?


Intercom isn't allowing me to upload images—that's annoying. Here's a Google Photos link of the 2 screenshots: https://photos.app.goo.gl/iUMxK5WQjSLxWfv1A

 

Effectively, in the first photo, I was just showing that I am first finding the Intercom ID (or creating one). The second is an example of the Webhook integration with all of the fields needed to action it. Here's what is possible with Zapier: https://help.zapier.com/hc/en-us/articles/8496326446989-Send-webhooks-in-Zaps/p>

 

Thanks again


Perfect thank you :)

 

I'm writing up the guide now should have it to you within the next hour!


So firstly here's a quick overview of APIs. I'm no expert and have just learned them recently, so I'll just explain in my own understanding.

 

At it's simplest form APIs just let you send or receive information from an app. It's how Zapier connects with all the apps it does, as well as other applications.

The most common type of API structure is a REST API which is what Intercom uses and what most things you'll encounter will use, but there are some that use GraphQL that are a bit more complex (but more powerful).

 

The main two types of 'requests' are GET and POST, which mean the following:

 

GET - Give me information

POST - Here, have some information (used to update things)

 

There are more, but these are the main two that you'll likely use.

 

As an example let's take a very simple, though also not that useful(sorry Intercom haha pls expand on this one) request you can make to get the total number of conversations you have within your Intercom setup. https://developers.intercom.com/intercom-api-reference/reference/conversation-counts/p>

 

You need a program like Postman (I recommend this for just testing API requests before you actually implement them somewhere) or just the Zapier web hooks.

Essentially you send a GET request to https://api.intercom.io/countsand it will return you code that looks like this:

 

{

"type": "count",

"conversation": {

"open": 30,

"closed": 17,

"unassigned": 0,

"assigned": 30

}

}

The format of this is called JSON, and the reason it's like this is so that it can have nested attributes (like indented) and so that other software can make a distinction between the 'attributes' and the values of those attributes. Essentially so that Zapier can recognize to get the number assigned to 'open' (30 in this case) rather than just the whole text.

 

Now how does https://api.intercom.io/countsknow to return your intercom data, as opposed to someone elses? Some companies will set up their API so that you would have your distinct ID within the URL itself, like https://api.intercom.io/YOURID/counts.However with Intercom they make it so that the Authorization method is what specifies your identity, so that it can return the data.

 

The point of advising the above is that, a lot of companies will do different things with their API, but it's all fundamentally the same, and once you understand what is merely just a slight difference in structure, you can easily adapt to using any API.

 

Now regarding Authorization, API calls will often require this, just like when you have to login to a website. It's up to the owner of the API as to which, if any(it's possible to set up an API to not require any authorization), type of authorization to use. For Intercoms case, they use a Bearer token. It's not really important to understand exactly what that is, just how you specify it in your settings.

 

-

 

Okay I could probably go on and on about understanding APIs haha so I'll move on to the steps to get what you need in this case, but happy to clarify any parts!

 

Step 1. You need to create an 'app' (while this is used for making actual apps in Intercom, it's also just required to make any api calls at all) within the developer hub.

You can click on 'your apps' at the top right and press 'create new' to do so. Call it whatever you like.

Step 2. Once you've made the app, the API version is going to by default be on v2.5. In this case we want to change it to v0, so click on 'API Version' in your app, then edit, then change it to V0.

imageStep 3. Click on 'Authentication' below 'API Version' and you'll have your token visible. Copy this, you'll need to use it with Zapier. This is the bearer token.

Step 4. We need to find the subscriptions IDs and I don't think you can find them within Intercom. If you already have them you can skip this step.

  1. Head to Zapier and within the webhooks step, select 'GET' request. We're going to use the list subscription request in order to find the IDs of your subscriptions.
  2. Make yours look like mine does in the photo below. Where it says 'Authorization', you want to enter in the right hand side: Bearer YOURTOKENTHATYOUCOPIEDEARLIER. You will put a space after Bearer, and ensure it has a capital B. If you need to screenshot this later be sure to censor the actual token, as you don't want to share that with anyone(outside your company).
  3. Press continue and review & test. You'll then get some data back (weew first API call!), and it will list all your subscriptions with the IDs. If you just need 1 ID then you can actually just save the data in a notepad and delete this step.

 

image 

Step 5. Okay so we have the subscription ID that we need for the next API call. So now make a new webhook step (or just edit the one from Step 4 if you don't need it anymore, either way) and select 'CUSTOM' as the option.

Step 6. Replicate how my photo below looks:

image 

This should work, I say that only as I don't have any subscriptions myself to test but the only way in which it may not work would be me entering something wrong within Zapier, so it'll definitely work either way just may need a tweak, but I think I've got it all right.

 

As you can see we're dynamically inserting the lead ID into the URL structure. Remember earlier when I said sometimes APIs will have the 'identifier' in the URL and sometimes in the authorization? In this case it has the identifier for the lead in the URL and that of course will automatically update each time it runs for a new lead.

 

You can of course change the 'opt_in' to 'opt_out' for other types of queries but for now you want opt_in of course.

 

Give this a go and hopefully this all makes sense! If you get stuck let me know, I'll be here to help 🙂


So good! I got everything and the very last step is giving me an error.

 

Failed to create a request in Webhooks by Zapier

The app returned "The Accept header should send a media type of application/json".

 

I googled it and tried different fields for Content-Type like:

Accept: application/json

 

But it didn't work.

 

Here's an image of my POST action.

Sorry about this again, but the Forum is not doing anything when I click Upload Image. I added a third image to this album: https://photos.app.goo.gl/iUMxK5WQjSLxWfv1A/p>

 

 

 


Hi Zak, so I've added in a 3rd field in the Header Accept: application/json and now I'm getting a different error:

 

Failed to create a request in Webhooks by Zapier

The app returned "Resource Not Found".

 

I also saw that my URL was missing .../contact/... so I've updated the screenshot in google photos.


Nice working on adding the Accept header, forgot about that one 😃

 

Can you take a screenshot of the error in the test& review section?


Oh wait I think I see what's wrong

 

Content-Type rather than Content_Type


Oops! My bad. New error though:

 

Failed to create a request in Webhooks by Zapier

The app returned "There was a problem in the JSON you submitted 6e0f659cf2bf5413e17b67f4dc393514]: logged with error code".

 

 

 


Try put data-pass through to 'false' and then test

And if that fails then also change unflatten to No


Yes, data-pass = false worked. You are amazing!


party 

Epic! Glad to help 😄

 

Once you get started with APIs it'll let you do all sorts of new things, especially with Zapier.

 

I'd highly recommend downloading Postman, a free application for testing APIs. It's great for testing out calls before implementing them in Zapier, as Zapiers fields are mighty confusing sometimes! There's some other cool things you can do with Intercom that Zapier doesn't have natively, like creating new tags. But anything you can see in the Intercom documentation you can do 🙂

 

If you ever need help with that stuff again just let me know 😎


@zak p​ one more thing — you can get the subscription ID in the URL on the Subscription Page, in case you need to tell people how to do this again.


Ah excellent to know! I was hoping that'd be the case, but didn't have any subscriptions to visit haha. Thanks for letting me know 🙂


Last question @zak p​ , if a user is already Unsubscribed from emails, it seems like I can't send an unsubscribe=false (see below) in Zapier or through webhooks (e.g. it doesn't uncheck the box in Intercom). Am I doing something wrong here?

"unsubscribe_from_emails": "false"

 


@zak p​ Just making sure you saw this in my flurry of messages.


Ah are you trying to filter the result by only users that are unsubscribed from emails?

 

If so, your thinking is correct, however sadly this is because the API doesn't support the filtering. You'll be able to see on each requests page in the documentation what parameters it supports for filtering the request; often it's missing some very obvious ones.

 

@Azure Radio 277​ Some more feedback to add additional filtering parameters.

 

However there are a few ways you can adjust this, I believe in Zapier there is a 'filter' step and you might be able to use this to extract only the data where they are opted in. Or you could send it to a google sheet, then make a new step to grab the info from there, there's definitely a few ways, some more optimal than others


Actually, no I'm not trying to filter. I'm trying to handle the edge case that the user unsubscribed first, but then they tried to opt-in to a specific subscription type (via the flow we discussed above).

 

So, The checkbox "Unsubscribe from all emails" is checked:Unsubscribed from all emails 

Then I sent a Zapier change to:

"unsubscribe_from_emails": "false"

and

POST a change to opt-in to a specific subscription.

 

But, the checkbox is still checked. If I uncheck it, I can see that my POST webhook worked though.


Ahh, are you trying to send that with the 'Attach a contact' or 'detach a contact' model?

 

I believe the unsubscribe_from_emails parameter is found in the Update a Contact model, so you'd need another request but going to a different URL (https://api.intercom.io/contacts/lt;id>) in this case, if you're not already.

 

Could the checkbox be a visual bug and perhaps it actually has applied? Times like this I'd definitely recommend downloading postman so you can run a separate GET request to see the raw attributes to see if it worked, though you can do it in Zapier too.


Reply