Ask a question
Instead of getting an ugly browser alert like this, wouldn't you rather Bubble send you an email with the error code and error message so that you can debug it and you don't annoy your users with ugly messages that look like they're full of coding jargon?
In this Bubble tutorial video, I'm going to show you how to do that. We're going to trigger an email to be sent to myself when my Bubble app has an error like this. In this case, it's an OpenAI error.
An unhandled error occurred
I'm going to click OK on that, close it down. I can do this by adding in an Unhandled Error Occurs workflow action. This is something that I think a lot of people overlook, but it's really powerful because just simply by having this workflow in place, it's going to stop that browser alert from showing up. And so then I just add in an action, so I can add in the send email action, put my own email address in here, the subject and body. And in body, I can put in the error code, and I can put in the error message.
How to send emails from Bubble
And just a quick word on sending emails, transactional emails in particular with Bubble. First of all, this is happening on the front end. So if I put an email address in here, it needs to be one that I'm happy that if one of my users really dug in with the browser developer tools, they would be able to access it. It's not going to be kept private. They can see it because this is happening in the frontend workflow. Also, make sure that this workflow action depends on you having the SendGrid API key set up in your settings tab in your Bubble account. If you've not set up the SendGrid API, then you'll need to set up an alternative transaction and email provider, and we've got videos covering all of that.
Last thing, in a separate video, you're going to want to add something else in here, because at the moment, this is just basically hiding the error from the user and then sending you an email. They're still going to encounter whatever issue is. So in the case that I demonstrated at the start of this video, my OpenAI key has been deleted, OpenAI API key has been deleted. And so my ChatGPT phone isn't going to work. So I suggest that you show them some alerts, and you can check out our videos about toast notifications to find out how to do that.