Send Custom Event card triggers an error in the st...
# 🤝help
w
Hi! I am using a Send Custom Event card in my flow. Works fine when deployed on my web page where the event is properly handled, but the emulator triggers an error when it reaches that card. Any idea ? Thank you!
The error message in the Logs:
The error in the javascript console:
f
Hey there. The cause of the error is that you are using it in the emulator and not webchat. It's made for Webchat, and cannot work in the emulator.
w
Thank you for your answer! Does it mean I cannot use the emulator anymore because I have put a Send Custom Event card ? I would have expected the emulator to just ignore that if it is not meant to be used by it
f
That is correct, it will throw an error every time in the emulator. You can just put it in a node that you don't use in your flow, when you are in your are using it in your emulator.
w
By any chance do you know if it is a known issue that is meant to be fixed at some point? I mean failing a bit more gracefully?
Also do you know a way to achieve the same behaviour (sending a custom event to the chatbot) from an Execute Code card ?
f
I don't think it's an issue. You will face the same issues when you use cards from other integrations that are meant to be used somewhere else than in the emulator.
Do you mean to the website?
w
Thank you @fresh-fireman-491. I think I am probably missing the point of the emulator. In my mind it was meant to support every use case we can craft using the studio editor. Isn't that the case? In the situaton of the Send Custom Event card, I would expect the emulator to have the knowledge that the card is "not supported" by it and just continue the flow, instead of failing internally with a 500 server error. What am I missing here ?
Let me clarify what I am trying to achieve here. Initially, I wanted to hide the text input (composer) in some specific situations on mobile, because I didn't like it that when a user clicks an option, the text input (composer) automatically gets the focus and opens the mobile keyboard. It gives a bad user experience in my opinion. The solution I found for that implied using Custom Events. It works beautifully when integrated on my website, but unfortunatelly triggers those Unknown Errors in the Emulator
f
Maybe @famous-jewelry-85388 can enlighten us here? Just about the 2 last messages from Drakoleptic
w
@famous-jewelry-85388 some help would be really appreciated 🥹
f
Hi @wonderful-guitar-98984 , Yes it always throws an error in the emulator, what you can do is: 1- Add a transition that detect if the user is coming from the emulator or not (check attachment) 2- If they are coming from the emulator, you can set some variables (that you will use later) in an execute code card (check second attachment) https://cdn.discordapp.com/attachments/1218925927707185277/1221910555753844886/image.png?ex=66144be2&is=6601d6e2&hm=344b889b36d9ce82a859bcdaefa42f1e84d7809dd9f94d685334801196634032& https://cdn.discordapp.com/attachments/1218925927707185277/1221910556001439836/image.png?ex=66144be2&is=6601d6e2&hm=fa327da3fd20bf7d4ebdee0269415184a4b2829720aefef87330a48b3b02cee8&
3- Then otherwise, connect the node to where you want to call the card you want
I hope that was clear explanation to for that point
w
@famous-jewelry-85388 Thank you very much Bassam for this explanation and workaround. But it would really complexify my flow and impact clarity just for testing purpose, which is a pattern i avoid at all cost in software development. Because I use "Send Custom Event"several times in my flow. Is there any chance this gets "fixed" at some point ? I cannot imagine I am the only one using the "send custom event" card and wanting to test my chatbot in the emulator. Am I ?
I understand the context of the emulator is different than the one of the webchat, but in the end, one context will not handle the custom event while the other one will. can't the emulator just ignore the event instead of triggering a 500 error? Can I contribute in "fixing" that ?
f
Hi @wonderful-guitar-98984 , I am with you about the complexity, I have reported it to the team. But to be honest we don't get that issue raised periodically as compared to some other features and issues.
However, I have reported it.
w
Hi @famous-jewelry-85388, I understand. Thank you very much Bassam for your attention and time.
f
Any time, One Team 💪