Custom workflow website trigger

  • 30 November 2023
  • 2 replies

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 6 December 2023, 07:07

View original

2 replies

Userlevel 3
Badge +3

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. 😊

Badge +1

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.