Scheduling emails using API workflows

Hi guys,

I’m currently trying to setup my app to send an automated email to new users 20 mins after they sign up but I’m struggling to work out how the API workflow part works. Specifically, I’m confused with what I need to enter in the Endpoint box shown below:

Any advice would be really appreciated.

Thanks so much

JT

Add a new parameter. Label it as User or something like that. Then make it a type user so you can access the person that signed up. See if that helps. :slight_smile:

1 Like

This is yet another wonky Bubble nomenclature issue. The things called “API Workflows” are multipurpose SERVER SIDE workflows that may or may not have ANYTHING to do with calling Bubble as an external API.

In your case, the “API Workflow” is nothing but a workflow you want to kick off at some pre-scheduled time. In this case, you do not want to expose the workflow as a public endpoint. It’s just for your app. (So to call this an “API Workflow” is silly and scary.)

The permissions settings can be useful though. The point of them is this: By way of example… Let us say that you have a button on your site like this:

image

When clicked, you throw up a pop up that lets the user compose a message that is destined for you, the admin. When they hit “send”, you kick off one of these API Workflows to send an email to another User (you and/or other admins).

However, due to Privacy Rules, random user has no permission to get your email (your User object’s email address).

What to do?

If “ignore Privacy Rules” is not checked, the workflow will fail as the User cannot get your User object’s email. Checking the box lets the workflow run like an administrator, a superuser, someone who has access to everything.

This is what you want in this case. You’re basically saying, “hey, app, after the user does X, schedule an email to be sent to them from the app at current date/time:plus minutes 20”. Also, “though the user has no rights to request this, honor the request anyway.”

Hope that helps!

3 Likes

Thanks for both of your advice! Very useful!

I’ve followed both pieces of advice. Makes total sense but still can’t get this working. Is there something I’m missing? Maybe some other checkbox needs to be ticked/unticked?

Thanks again

Things to check…

  1. You have a plan that allows API Workflows (so not Hobby)
  2. You have set up your SendGrid API Key in Settings Domain/Email
  3. Privacy as above (because the server isn’t your user)
1 Like

Thanks for the suggestions Nigel :pray:

  1. I’m on the personal plan
  2. The SendGrid API is setup correctly
  3. I’ve checked the “ignore privacy rules when running the workflow” checkboxes in the API workflow and on the page workflow

But alas, still not working :frowning:

Josh

Can you show the full workflow to us I.e where it is called/triggered and the sendgrid bit inside the api workflow.

I guess you are triggering it as a scheduled api workflow? Can you see it in the scheduled tab in the logs?

This will help us/you figureing out which bit is failing

Cheers
Simon

Here is the full workflow that I’ve got so far. Yes, I’m triggering it as a scheduled api workflow although I can’t see it in the logs, although I’ve never looked at the scheduled logs before. Thanks so much

API workflows


Page level workflow

Long shot, but I wonder if it the way the signup is working, and there is no actual “current user” at the time.

So I might be tempted to send the email they signed up with as a text parameter, and then use that.

Ah, I see what you mean. Just tried that but didn’t seem to work either. The issue with this is that the API workflow is set to send to “current user” and I can’t see any way round this as I can’t access input fields on the page that triggers the workflow?

Try adding a new table called “log” and then write “Current user’s email” to it so you can see what is in there, and where the process gets to.

Need to work out it the email isn’t getting passed, or the step isn’t running.

Ok, I wasn’t 100% sure what you meant but I created a text box to display the “current user’s email” and it displays the correct email straight away. Not sure if this is what you were meaning?

Thanks so much for the advice!

So that is good.

However you need to see if that is being passed to the API workflow. The workflow is run on the server, so may be different.

As there is no “screen” on the server, you would need to output to a table. Then have a look to see what is in there. Will give you an idea of where the problem is.

Yeah, makes sense. By table, do you mean creating a new Data type?

Yes, sorry, Data Type, with just a text field.

I’ve tried this and everything seems fine here too. Email address is written to the table successfully. I feel like I’m messing up the API workflow somewhere. Has anybody created a video on API workflows?

The next step would be to check in SendGrid to see if they are getting the email request.

Thanks so much for all your help. The issue was on the Sendgrid side. Not entirely sure what caused the problem as I played around with a lot of settings, but I suspect it is because my domain was not authenticated s I had not added their DNS records.

Thanks again for all your help. I really appreciate that! :pray:

1 Like

Good work in tracking that down :male_detective:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.