Skip to main content
Answered

Custom workflow website trigger

  • November 30, 2023
  • 2 replies
  • 166 views

Hey everyone I am trying to setup a custom workflow that opens when users click on a button 

I added this class name to the button “workflow-trigger” and it works well when the button is directly visible in the page. 
My problem is that I want to display this button dynamically inside a modal. In this case the workflow doesn’t trigger and I suspect that it’s because the button is not available in the DOM immediately. 

Could this be the case? If yes is there another recommendation to trigger a workflow on a button click?

Best answer by aykut.aydin

Hey @dimikara 👋

 

From your description above, it seems like your element cannot be found. This typically occurs if the CSS selector for the targeted element is dynamic. Could you make sure if your element still has the same class name when it is inside the modal?

 

Also, the best way to target elements for Intercom would be to use specific Intercom attributes, like shown in our article here. This article was for Product Tours, however, it works with the same logic when it comes to element targeting for Workflows.

 

Could you use data-intercom-target=… in your element and let me know if you are now able to trigger your workflow? In the Workflow builder, you will need to make sure that the element is targeted via the attribute like the below example.

 

If you are still having issues with targeting the element, alternatively you can consider using “customer visits a page” trigger in your workflow, and trigger it via event. For example, you can submit an event whenever the user clicks on the button, and use that event to trigger your workflow like the below:

Let me know how it goes when you test the data-intercom-target attribute on your element. 😊

View original
Did this topic help you find an answer to your question?

2 replies

aykut.aydin
Employee
Forum|alt.badge.img+4
  • Customer Support Engineer
  • 104 replies
  • Answer
  • December 6, 2023

Hey @dimikara 👋

 

From your description above, it seems like your element cannot be found. This typically occurs if the CSS selector for the targeted element is dynamic. Could you make sure if your element still has the same class name when it is inside the modal?

 

Also, the best way to target elements for Intercom would be to use specific Intercom attributes, like shown in our article here. This article was for Product Tours, however, it works with the same logic when it comes to element targeting for Workflows.

 

Could you use data-intercom-target=… in your element and let me know if you are now able to trigger your workflow? In the Workflow builder, you will need to make sure that the element is targeted via the attribute like the below example.

 

If you are still having issues with targeting the element, alternatively you can consider using “customer visits a page” trigger in your workflow, and trigger it via event. For example, you can submit an event whenever the user clicks on the button, and use that event to trigger your workflow like the below:

Let me know how it goes when you test the data-intercom-target attribute on your element. 😊


Forum|alt.badge.img+1
  • Connector
  • 9 replies
  • May 30, 2024

Yes, the issue could be that the button inside the modal is not in the DOM immediately, so the workflow doesn't trigger. To fix this, you can use an event listener that detects when the modal content is loaded and then attaches the click event to the button. This way, when users click the button, the workflow will trigger as expected. I did the same practice at my website thapcamtv when I faced the same issue. 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings