https://discord.gg/botpress logo
Custom trigger workflow not working as expected
# 🤝help
s
When sending a Webchat Custom Trigger event from the browser, the workflow does not execute from the trigger if the workflow is already on a different node. Screenshots have the simple workflow and two test cases with actual and expected results (expected results are in the console comments). Is this a bug or expected behavior? I've spent hours fighting with this problem so any help is greatly appreciated. https://cdn.discordapp.com/attachments/1389717441604485131/1389717442644934816/image.png?ex=6865a2ba&is=6864513a&hm=af715dabcb1cbdc0a8e40a39371243b4931c0c9f3c548289f119de7580de43ba& https://cdn.discordapp.com/attachments/1389717441604485131/1389717443122827334/image.png?ex=6865a2ba&is=6864513a&hm=3474673419c3bb2f0934da3b456e1e193b5dba8350a306c76a03e97ba9d20ea8& https://cdn.discordapp.com/attachments/1389717441604485131/1389717443567554720/image.png?ex=6865a2ba&is=6864513a&hm=730e8d622ef8972f2551d73d70a2e6c66b01a14a8f0a3b986d839bcc1df862ec&
l
Event trigger needs a conversationId
s
Thanks for the help @jolly-musician-13546 ! I added a conversationID (alone), as well as a conversationId and userId (together) and its still not working. Do these settings look right? https://cdn.discordapp.com/attachments/1389717441604485131/1389964797914779780/image.png?ex=68668918&is=68653798&hm=443464411e01dd817411c7ca69ec831c4f2c4092059738066d72224af84b07b4&
l
you need to pass conversationId from the browser in the payload and then attach the conversationId you received to event.converstaionId say your are sending
Copy code
botpress.sendEvent(
{
    "conversationId" : "the actual conversationid",
    "type": "test-event"
})
then in the conversationId you should add {{event.payload.body.converstaionId}} and not {{event.conversationId}}
s
Ah ok. Let me try that. Thanks!
I appreciate the assistance! @limited-pencil-78283 So, its still not working. The workflow never transitions back to the Custom Trigger action when the event is received and its just stuck on Standard2. I tried several combinations of payloads and conversationId field settings: - sendEvent w/ conversationid plus these node settings:
{{ event.payload.body.conversationId }}
* (this expression does not seem to be valid btw)*
{{ event.payload.payload.conversationId }}
{{ event.payload.conversationId }}
I also updated the "here" message to include a dump of
event.payload
. I see
event.payload.conversationId
is there without me adding it to
sendEvent
. I also see that
event.payload.payload.conversationId
seems valid if I manually add it to
sendEvent
. Is this just a bug or can someone else get this to work?
l
I hope you are looking at published not emulator as this will not work in emulator also check logs in the dashbaord to check if you are receiving the event itself Jul 2, 2025, 7:19:27 PM [18531a4c97] [dm] : Event of type webhook:event received
s
yes, its the published bot that has this behavior
the event is in the logs. heres a snippet (I removed the actual ID's - not sure if they are sensitive or not).
Copy code
Jul 2, 2025, 10:26:05 AM
[4a98ddd416]    [dm]    :     Event of type webchat:trigger received.
Jul 2, 2025, 10:26:05 AM
[4a98ddd416]    [agent-hook]    [KnowledgeAgent] [conversation_turn_started]:     Skipping KB: disabled for the current turn
Jul 2, 2025, 10:26:05 AM
[4a98ddd416]    [dm]    :     Transition from (flow:Main) [node:Standard2] to [node:Standard2]
Jul 2, 2025, 10:26:05 AM
[4a98ddd416]    [dm]    :     Sending Message. Type: text. Text: here. event.payload = {
  "origin": "website",
  "conversationId": "<removed>",
  "userId": "<removed>",
  "payload": {
    "conversationId": "<removed>",
    "type": "test-event"
  }
}
Jul 2, 2025, 10:26:06 AM
[4a98ddd416]    [dm]    :     Waiting for user input
l
ah great
so I see conversationId is already there in the paylaod, you need to add them again
s
Also, heres what the log looks like if sendEvent is the first action in the workflow. This looks correct to me but sharing for completeness.
Copy code
Jul 2, 2025, 10:25:57 AM
[8db3477a56]    [dm]    :     Event of type webchat:conversationStarted received.
Jul 2, 2025, 10:25:59 AM
[aecebbca21]    [dm]    :     Event of type webchat:trigger received.
Jul 2, 2025, 10:26:00 AM
[aecebbca21]    [agent-hook]    [KnowledgeAgent] [conversation_turn_started]:     Skipping KB: disabled for the current turn
Jul 2, 2025, 10:26:00 AM
[aecebbca21]    [dm]    :     Starting from Trigger
Jul 2, 2025, 10:26:00 AM
[aecebbca21]    [dm]    :     Transition from (flow:Main) [node:Trigger1] to [node:Standard1]
Jul 2, 2025, 10:26:00 AM
[aecebbca21]    [dm]    :     Sending Message. Type: text. Text: custom trigger received.
Jul 2, 2025, 10:26:00 AM
[aecebbca21]    [dm]    :     Transition from (flow:Main) [node:Standard1] to [node:Standard2]
Jul 2, 2025, 10:26:00 AM
[aecebbca21]    [dm]    :     Sending Message. Type: text. Text: here. event.payload = {
  "origin": "website",
  "conversationId": "<removed>",
  "userId": "<removed>",
  "payload": {
    "conversationId": "<removed>",
    "type": "test-event"
  }
}
Jul 2, 2025, 10:26:00 AM
[aecebbca21]    [dm]    :     Waiting for user input
and in the execute code card you add this line event.conversationId = event.payload.body.conversationId then add a text card after in which you add {{event.payload.body.payload.type}}
s
ok let me try that
l
also add console.log("Payload ", event.payload) in the execute code card
just to be sure that the payload is received and we can see it in the logs
s
Still not working, same behavior
i do see this in the logs. maybe i need to also set the user?
Copy code
Jul 2, 2025, 10:52:48 AM
[70edb12c28]    [dm]    :     Cannot save state agentsUserVariables for user because the ID is missing ({"bot":"<removed>","user":"","conversation":"<removed>"})
l
this is fine
do you see console.log("Payload ", event.payload) logs?
check dm
s
re: console.log(), yes on the first sendEvent, no on the second sendEvent (b/c it seems to be stuck on the Standard2 node)
l
@prehistoric-airplane-85682 - I checked this with @square-king-46874 and the behavior is a bit strange the workflow is that webchat event ->trigger -> standard node (text card) -> Autonomous node (print values from event.payload) when the first event is sent to the trigger it works prints the text card content prints event.payload when the second event is sent to the trigger it skips the text card and only the event.payload is printed wherein the bot receives the event at the trigger and there is a text card in between the trigger and the autonomous node
p
@square-king-46874 Could you send a report id I would love to experiment with the funky behaviour? @limited-pencil-78283 thank you for the diagnosis :))
s
@prehistoric-airplane-85682 how do I send a report id?
p
There is a resource button in the studio where you can click report a problem and fill in the info. It will generate the report_id please paste it here.
s
@prehistoric-airplane-85682 thanks, here's the report_id: report_01JZ8SW3BDH64VRHGDPK147354
3 Views