Code for Button Click to Open Chat
# 🤝help
s
I need help to figure out how to open Botpress chat on WordPress website with click of the button. I am using Elementor Page Builder in case if that helps. Please assist asap. Thank you 🙂
b
Check this out, it could help you: https://jsfiddle.net/GordyNumberOne/pbhf3L0d/71/
s
@brainy-summer-1041 Thank you for sharing this, I am not a coder. I see there are a few different triggers for the bot in the code. Can you please break-down for me and let me know what code I need to add to the website? Thank you heaps 🙂
b
The code is on the left side of the screen
Just choose the kind of button you’d like to add and copy the relative code
s
// Load the Botpress Web Chat JavaScript library. const botpressWebChat = window.botpressWebChat || {}; // Initialize the Botpress Web Chat library. botpressWebChat.init({ "composerPlaceholder": "Chat with Bot", "botConversationDescription": "Bot by BotPress", "botId": "a3c3c7c9-57ca-4a72-96d3-d025c69e5399", "hostUrl": "https://cdn.botpress.cloud/webchat/v0", "messagingUrl": "https://messaging.botpress.cloud", "clientId": "a3c3c7c9-57ca-4a72-96d3-d025c69e5399", }); // Attach an event listener to the
startChat
button. document.getElementById('startChat').addEventListener('click', function() { console.log("triggering bot..."); botpressWebChat.sendEvent({type:'trigger'}); });
does this look correct to you? It is not working
b
Do you want the popup in the low right corner?
Or a dedicated button to click that opens the chatbot
s
both
I want the chat bubble in the right corner and click button to open chat
the button id is set to startChat
I was trying to share a screenshot, but it is saying failed to send the message

https://cdn.discordapp.com/attachments/1146298037778522233/1146552648762400798/Screenshot_2023-08-31_7.09.19_AM.png

https://cdn.discordapp.com/attachments/1146298037778522233/1146552874348847294/Screenshot_2023-08-31_7.11.25_AM.png

@brainy-summer-1041 Hi Michele, are you still around to help with this? Thank you 🙂
b
You probably won’t be able to do it, it’s an Elementor button and it doesn’t have a custom code section
You can try to add a custom code block and paste in the html code
s
Okay, so make a button with HTML and then run this code?
b
The code should already create a button (just like the ones in the link i sent you)
11 Views