Can I use regexp to hide operator on the product page? | Community
Skip to main content

For example, I have this URL pattern in my node app — /:lang/:citySlug-d:cityId(d0-9]+)/:productSlug-p:productId(d0-9]+)/

Example — https://mywebsite.com/en/barcelona-d1/el-born--picasso-museum-p19//p>

 

How do I hide operator on pages, which follow this pattern?

Hey @kirill c​! Do you mean Operator's task bots, or a Custom Bot?


Hey! I mean the settings to control inbound communications, so I need to hide Intercom button on some pages as described


Got you! I'm afraid my regex reading skills are pretty poor 🙈 which would be the variables in that URL? Looks like the language, city and product?


Yes, you are right. No worries, I am also noob in regexp, however see this example in online regexp tool — https://regex101.com/r/biZs5t/1/p>

 


Gotcha, thank you! I've checked with our team and I'm afraid we don't support regex in the Messenger visibility settings. However, that doesn't mean that you can't do what you want to do! How many possible language variations are there in the URL? (e.g. /en/, /fr/ etc.)


Intriguingly. How? For now, I have two language versions, but product slug could contain any a-z character


What I'm thinking here is using the options:

 

Page URL starts with https://mywebsite.com/en//b>

OR

Page URL starts with https://mywebsite.com/fr//b>

 

Or am I naively thinking that the only slugs that will follow language are the product and city ones?


I can give you more context. Here is a few examples of

  • Cities (Intercom Icon Button needed)

https://example.com/en/paris-d3/

https://example.com/en/barcelona-d1/

 

  • Products (Intercom Icon Button is not needed)

https://example.com/en/barcelona-d1/the-basilica-of-the-sagrada-familia-p13/

https://example.com/en/paris-d3/la-sainte-chapelle-p58/

 

What conditions come to your mind to make it work?

 


In the "Cities" slug, how many possible variations of d1, d3 are there?


Hey Eric! It could be thousands of them. We launched a website, you can check it out here: https://wegotrip.com/p>


Thanks for clarifying that for me! I'm starting to think that the best solution available to you here is a programatic one.

 

You can include a hide_default_launcher: parameter in your Messenger script. My recommendation would be to set up a script, using your regex, that changes the value of this parameter from false to true (a true value hides the launcher). What do you think?


Hey @eric f11​, I found a way to do the desired behavior. I use Google Tag Manager to install Intercom on my website, so I just created a new tag with JS code hiding Launcher with trigger on specific pages. It worked great.

 

Side note: to convert paths I had, I use node lib 'path-to-regexp', e.g. path `/:lang/:citySlug-d:cityId(I0-9]+)/:productSlug-p:productId(I0-9]+)/` become `^\/(?:(?^\/]+?))\/(?:(?^\/]+?))-d(?:(?0-9]+))\/(?:(?^\/]+?))-p(?:(?0-9]+))\/?$`.

 

Screenshots of my set up:

 

I hope it will help someone.


That's amazing, @kirill c​! Delighted that you found a workaround - how long do you have this in production? Have you encountered any unexpected behaviour?


This would also be a great one for our @Tips, Tricks, and Workarounds​ group!


We also use GTM to deploy the code snippet and you have lots of creative ways to fire or not fire the code based on page, time of day, day of week, etc...


Reply