Trigger happy chatbot?
# 🤝help
b
I would like the chatbot to post a message but keep the chat window closed. The idea is that this way the user will be triggered enough to open this window himself and answer the question. Looking at the tutorials and attempts so far have unfortunately been unsuccessful. Is it possible? If so, how?!
q
mean likes this?

https://cdn.discordapp.com/attachments/1147563119091138571/1147582637217681468/3434345e.PNG

this is code " your pre-config embed code and below this window.botpressWebChat.onEvent( function (ev) { window.botpressWebChat.sendEvent({ type: "loadConversation", }); }, ["LIFECYCLE.LOADED"] ); window.addEventListener("message", function (event) { // console.log(event.data.type); if (event.data.type == "LIFECYCLE.READY") { window.botpressWebChat.sendEvent({ type: "trigger", channel: "web", }); } }); "
b
Thanks! In the image is the result I want, but after using you code on my site it doesn't get a notification. When I open the chat window the chat begins loading and shows a message.
q
are you using wordpress? can you show me your trigger node?
maybe this helps and modify code https://botpress.com/docs/cloud/toolbox/events-triggers/, I use this code on wordpress and it works curently on 2 sites
can you open it in incognito mode on chrome?
to test
here is how my trigger node looks

https://cdn.discordapp.com/attachments/1147563119091138571/1147644121528414278/435353e.PNG

b
Yes, I am using WordPress. Tested it in incognito mode.

https://cdn.discordapp.com/attachments/1147563119091138571/1147644812577734786/Screenshot_2023-09-02_at_23.29.55.png

Thanks @quiet-raincoat-89190, I have tried all kinds of code. When you open the chat window is the chat there, or does it need loading?
I have the suspicion there is no notification visible.
Can I see one of you implementations?
q
this code triggers after page is loaded. That means when page is loaded you get "Hi" msg and that notification. hmm
I use WPCode plugin
b
That's what I thought. Must be doing something wrong
q
this is my code inside wordpress using WPCode in footer. also deleted inside my id, but it looks like that. just with id, which dont wana share.

https://cdn.discordapp.com/attachments/1147563119091138571/1147646244089503744/435434534e.PNG

alsodont forget to clear catche
b
Thanks again. My code seems right. I will try it again on a blank page and without plugins.
q
maybe its loading too fast for you, maybe you need 3 seconds delay?
let me see
add this " window.botpressWebChat.onEvent( function (ev) { window.botpressWebChat.sendEvent({ type: "loadConversation", }); }, ["LIFECYCLE.LOADED"] ); window.addEventListener("message", function (event) { // console.log(event.data.type); if (event.data.type == "LIFECYCLE.READY") { window.botpressWebChat.sendEvent({ type: "trigger", channel: "web", payload: { text: "", }, }); } }); " maybe you were missing payload, if not let me see delay
this is delay code "window.botpressWebChat.sendPayload({ type: "trigger", payload: {} }); }, 3500);*/ // 3.5 seconds, not too short to let it load, not too long to have a message too delayed" maybe 3.5 seconds helps, check
trigger looks like that? some people had bug and it didnt show like that

https://cdn.discordapp.com/attachments/1147563119091138571/1147648703780356287/45454.PNG

b
Just discovered it works fine on clean html, so it must be a plugin that's getting in the way. Thanks again for your help and patience @quiet-raincoat-89190
q
Np, I had same strugles, first time with wordpress, I am more kind of backend developer, with minimum front end 😄
here is code if you want to know on what page user is " window.botpressWebChat.onEvent( function() { window.botpressWebChat.sendEvent({ type: "loadConversation" }); window.botpressWebChat.onEvent( function(event) { console.log('RECEIVED FROM STUDIO ==>', event); // if (event.value.type === 'navigate') { window.location.href = event.value.url } }, ["TRIGGER"] ); }, ["LIFECYCLE.LOADED"] ); window.addEventListener( "message", (event) => { console.log("message from iframe", event); }, ); function sendPayload() { var textInput = document.getElementById('textInput'); var text = textInput.value; window.botpressWebChat.sendPayload({ type: "trigger", payload: { text: text, currentUrl: window.location.href } }); textInput.value = ''; } " I didnt test this code yet, but it will be important for me when I am done with Ai + tables. Idk if this code works, but can save it and modifie it.
6 Views