Auto-messages and the /initialize request


#1

Hi all,

I noticed that whenever my app gets inserted via auto-messages there’s no request to the initialize endpoint and the canvas that gets rendered on the card comes from a “cached” version. Can you shed some light on what’s the request flow on auto-messages and when does that “cached” canvas gets stored and invalidated?

Thanks!


#2

Hey @marino – both the configure and the initialize calls happen when inserting the App into the message. This happens for a few reasons:

When you’re creating a message in Intercom you specify a set of filters (for auto messages) or the user(s) (for manual messages).

In the case of auto messages

The filters specified at message creation are only used to call up the list of matching users at the moment of sending. We do this to ensure that only the users that currently match the message at the time of send are actually sent the message. Because of this the initialize call needs to happen at message creation – otherwise the following three things could happen:

  1. You might store app canvas data for users that won’t receive the message
  2. Or not have canvas data for users who will receive the message
  3. Or you could have incorrect data for users that receive the message because their user data has changed in the intervening time period between message creation and send.

In the case of manual messages

While you already know the list of users who will receive the message, case 3 above still applies.

Ok, that makes sense. But my app shows custom content based on user data.

For apps that need to customer card content based on the user that the app is being shown to the suggested (only?) way to do this is to use the live canvas endpoint and store some degree of state on your side about how far a given user has gone through the flow of your app (otherwise you’ll continue to reset the card to it’s initial view each time the messenger or your app reloads).

Hopefully all of this makes sense. I’ve gone pretty detailed here in the hopes that this is helpful for others that come across this same issue. :slight_smile:


#3

Thanks for the details Jeff. I was able to adjust our flow in order to work properly with auto-messages!


#4

yeah. I had to adjust ours too. Would be good to add that info to the documentations. (Support for auto messages came in a bit later, so it wasn’t mentioned at all if I recall correctly).


#5

That’s 100% true. We’re working on adding it now actually :slight_smile:

cc/ @zach


#6

Looks like the previous link shared no longer exists. This should be the current link to the docs https://developers.intercom.com/building-apps/docs/request-flows#section-live-canvas-flow :+1: :grinning: