Trigger not working
# 🤝help
h
Following the Botpress documentation, have tried using both the following triggers but only the first one works. Any suggestions as to why? setTimeout(() =>window.botpressWebChat.sendEvent({type:'show'}), 5000); setTimeout(() =>window.botpressWebChat.sendPayload({ type: "text", text: "Hello Chatbot!" }), 5000);
h
Up
a
Hey @helpful-kilobyte-18816 try staggering your triggers by a few milliseconds. The bot only responds to the first trigger (if multiple are received at once). So if you change the timeout on the
sendPayload
to be 5050 instead of 5000 it should work better
h
Thanks @acceptable-kangaroo-64719 however still no luck. Also if I use the second line of code by itself, nothing happens. I was expecting to hear the bell and see a number on the chatbot icon.
* sighs *
h
probably needs more time to be usable, they just came out of beta
h
@acceptable-kangaroo-64719 Still no luck here, any ideas why Payload text is possibly not working for me?
a
what's the code you're using?
h
See my first message. Copied from the help documentation. First line of code works the second doesn't.
a
@witty-football-93730 do you have any idea why one of the triggers would be processed but the other wouldn't?
h
Hola @acceptable-kangaroo-64719 I finally got it to work. There needs to be a much bigger gap between the two triggers. setTimeout(() => window.botpressWebChat.sendEvent({ type: 'show' }), 5000); setTimeout(() => window.botpressWebChat.sendPayload({ type: "text", text: "Hello!" }), 6000); // Increased the delay here I have a few observations, not sure if bugs or by design (I'm not a programmer): 1) The sendPayload "text" does not work by itself (needs the sendEvent "show" to be triggered first) 2) The sendPayload "text" only works after the sendEvent has been triggered (you can't push the text and then get the bot to open) 3) when you send text it appears as if the customer wrote it and triggers the bot to start chatting. Shouldn't the text be a greeting from the bot which awaits a response from the customer? 4) Realistically the bot should only be triggered once. It's really annoying for a customer to have the bot popping up every page they land on. And on every page it triggers the same greeting after which the bot responds with "sorry I dont know the answer to that, please try again" ...... over and over again with every page you visit. Realistically I really want the bot show an unread message alert, but seems I opened a can of worms here.
a
Thanks for the update! A can of worms indeed. Since there is also a "show webchat" card in the studio, I wonder if it would be possible to send a single custom trigger to the bot and then the bot handles the showing?

https://cdn.discordapp.com/attachments/1138692652112556152/1145669668271566868/image.png

h
What is the event.conversationID that that card refers to? Searched Help documentation and found nothing. Not sure if you're aware the video you made about triggers is not available. I actually just want to send a message with the bot being closed so that the user sees there is a message but the bot doesnt pop up on every page, distracting the user from navigating the website. This should be a simple on/off button, Botpress seems to like making many things overly complicated. 🙃
a
conversationID is in the event object as
event.threadId
. The video got moved to private because triggers have changed significantly since the video was recoded and the video's method of triggers no longer works. I'll try to put a new triggers video out this week
h
ok thanks, await it with anticipation. 🔥
189 Views