This repository provides some JavaScript that can be used to create a Bookmarklet to inject a Dialogflow Chatbot into the current webpage, if security policies allow.
The injection is done purely by manipulating the HTML in the browser. No remote services are affected by using this bookmarklet.
- Open and copy the contents of inject.js
- In the browser, right click on the bookmark bar
- Select the "Add page" option
- Give the bookmark a name (e.g "Inject Chatbot")
- In the URL, paste the contents of the inject.js file
- Done!
- Open the website you want to inject the Chatbot into
- Click the bookmarklet, you will be prompted for some details
- Fill in the required details, which can be found by performing the following:
- Visiting the Dialogflow CX portal and selecting your project and agent
- In the "Manage" section, select "Integrations"
- Under "Text Based", find "Dialogflow Messenger" and click "Connect"
- Extract the values of the "project-id", "agent-id", "language-code" and "chat-title" attributes in the code example
- Paste each value into each respective input
- Add any styling you'd like the bot to have (you can see what styles can be applied here)
- When finished with the configuration, click "Go!"
- The Chatbot should appear in the bottom right
This is most likely because the website doesn't allow external content to be loaded, meaning this menthod will not work. The bookmarklet should present you with a warning if this is the case. You can verify by checking the JavaScript console for an error. (ctrl/cmd + I, then select "Console"). Unfortunately, you will need to use another method.
Simply reload the page.