# Een externe bot starten en een bepaalde flow in een iframe activeren

**URL:** <https://meta.discourse.org/t/starting-an-external-bot-and-trigger-a-certain-flow-in-an-iframe/164064>\
**Category:** Product Support\
**Created:** [15 september 2020 om 07:36 UTC](https://meta.discourse.org/t/starting-an-external-bot-and-trigger-a-certain-flow-in-an-iframe/164064 "2020-09-15T07:36:16Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Krischan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/krischan/32/47290_2.png) [@Krischan](https://meta.discourse.org/u/Krischan)\
**Post date:** [15 september 2020 om 07:36 UTC](https://meta.discourse.org/t/starting-an-external-bot-and-trigger-a-certain-flow-in-an-iframe/164064/1 "2020-09-15T07:36:16Z")

</div>

We’d like to include a 3rd party bot in our Discourse site to help new users understand what our community is all about before they join it and pay a membership fee (via the [subscription plugin](https://meta.discourse.org/t/discourse-subscriptions/140818/143)). We’d like to trigger this bot from posts and CTAs around the site via a link / button click and start a predefined flow in the bot.

The Bot ([Here’s an example](https://fxo.io/m/d224xnkv)) can be integrated via an iframe or via this script before the closing body-tag:

```
<script src="https://widget.flowxo.com/embed.js" data-fxo-widget="eyJ0aGVtZSI6IiM2N2MxOGUiLCJ3ZWIiOnsiYm90SWQiOiI1ZjYwNmFmZGJhYmU5NjAwNGIwODc4NTMiLCJ0aGVtZSI6IiM2N2MxOGUiLCJsYWJlbCI6IkV4YW1wbGVib3QifX0=" async defer></script>

```

So I (non-coder 😉) built a theme component with the code above and an additional script that triggers a certain flow when a link with a certain ID is clicked:

```
<script type="text/javascript">

        // Wait for the page to load first 
        window.onload = function() {

          //Get a reference to the link on the page
          // with an id of "mylink"
          var a = document.getElementById("mylink");

          //Set code to run when the link is clicked
          // by assigning a function to "onclick"
          a.onclick = function() {

            // Your code here...
            FxoMessenger.create();
           FxoMessenger.on('stateChanged', function(state) {
      if (state === 'connected') {
        FxoMessenger.sendMessage('This is the text that triggers the flow in the bot!');
      }
    });
            //If you don't want the link to actually 
            // redirect the browser to another page,
            // "google.com" in our example here, then
            // return false at the end of this block.
            // Note that this also prevents event bubbling,
            // which is probably what we want here, but won't 
            // always be the case.
            return false;
          }
        }

```

This works in theory, but, unfortunately, the ID is automatically removed from a link in a Discourse post. Is there a way to achieve this? Thanks for your help!

---

_[View the full topic](https://meta.discourse.org/t/starting-an-external-bot-and-trigger-a-certain-flow-in-an-iframe/164064)._
