This code is not working, how can I add dialogFlow tags to a whole site editing just this one .JS file, without adding tags manually to each page.
var script = document.createElement("script"); // create a script DOM node
script.src = "https://www.gstatic.com/dialogflow-console/fast/messenger/bootstrap.js?v=1";
document.head.appendChild(script);
var div = document.createElement("div");
document.getElementsByTagName('body')[0].appendChild(div);
div.outerHTML = "<df-messenger chat-title=\"Help\" agent-id=\"id" language-code=\"en\" ></df-messenger>";
This solved it
document.addEventListener("DOMContentLoaded", function() {
//code here
});