+1 this. Changing the webpage UI / state based on messenger interactions would be gold.
Unfortunately, it would also be pretty insecure – it’s very unlikely that we’ll enable this in the future.
I’m not yet able to fully test this yet, but I think it may be possible to securely do this using the method below.
The idea would be to have a clientside js connect to your server via websocket or SSE. It would use the logged in intercom user_id as a client_id for identification.
When a Messenger App event happens, you can pass the json to your websock backend, process the event details and emit data back to the client which can then be used to modify the webpage UI/state.
Yes you’re exactly right Andrew. That renders the HTML page returned within the context of the iframe of the Messenger itself, rather than on the client DOM.
Is there a way to detect if Intercom Messenger is available?
I noticed that too yesterday, thought it was an issue on my end. Seems to be working today.
For logged in users, you have access to the user_id since it’s a value you created.
EDIT: Intercom(‘getVisitorId’) is working on my dev account which was just setup today for messenger apps. My main live account, which is not yet upgraded to the new messenger, doesn’t work.
@marcel that’s odd. I’ve just double checked with an account we have running the new Messenger and
getVisitorId is working correctly
Hey @jonny, I uploaded my test HTML to a S3 button so I could show it to you, but the uploaded version does work. It is only the version that is served using ngrok that doesn’t output a valid visitorId. I also tried it on localhost and that also works fine. Apparently it is the combination ngrok/intercom that does not work but I don’t know what (I don’t see any difference in the HTML or headers). So it is not a big deal if it is only ngrok.
Hey @marcel I actually think I know what’s going on here. Were you using ngrok as a host to actually boot into your workspace?
i.e. you went to
https://ngrok.io/12323521341/mysite which loaded your page where the Messenger exists?
If you do that, it isn’t a proper domain, and we can’t place a cookie on the page, so every time you reload the page it’ll update the cookie and change visitor!
Nice one! Yup that’s exactly it. We aren’t able to place a cookie on domains like that @marcel so that’s why that isn’t returning anything.
You should really only use ngrok for webhooks and then use localhost for development (because we can place cookies on localhost )
Yes, that is perfect for testing.