ย ยทย Business Owner

Javascript to Dart

You might figure from this question that I am not a developer so please forgive me if this is too outrageous. I have some JS code that essentially embeds a voiceflow chatbot into a web page and I want to know if I can "convert" the code to Dart and create a widget. I have looked at the VF api and while I am sure it's possible to implement it, it's way over my head and therefore, I'm looking for an easier option.

<script type="text/javascript">
    (function (d, t) {
      var v = d.createElement(t), s = d.getElementsByTagName(t)[0];
      v.onload = function () {
        window.voiceflow.chat.load({
          verify: { projectID: '***' },
          url: 'https://general-runtime.voiceflow.com/',
          versionID: 'production'
        }).then(() => {setTimeout(() => {window.voiceflow.chat.open();}, 500)});
      }
      var interval = setInterval(function () {
    var chatDiv = d.getElementById('voiceflow-chat');
    if (chatDiv) {
        clearInterval(interval);

        var parentDiv = d.getElementsByClassName("inner")[0];
        var targetDiv = d.getElementById('contact');
        parentDiv.insertBefore(chatDiv, targetDiv);

        //targetDiv.appendChild(chatDiv);
    }
}, 100);
      v.src = "https://voiceflow.seefusion.tech/embed/widget/bundle.mjs"; v.type = "text/javascript"; s.parentNode.insertBefore(v, s);
    })(document, 'script');
  </script>
1
9 replies