Recurring email with dynamic CSV attachments

I need to send a daily report (csv ) attached in an email to the analytics team.
How can we achieve this ?
@adamhholmes @keith

Really depends on the mail service you’re using.

With Sendgrid you can add the file path to the API call and get it to work
Ref: Sending Attachments with Digioh | Twilio

On the other hand the Gmail API requires you to generate a base64 encoded email payload containing the attachment’s base64 string -all in a very specific RFC2822 compliant format (which is kind of a pain to set up in my experience).
Ref: Sending Email  |  Gmail API  |  Google Developers


Cheers,
Ranjit / Atomic Fusion: Accelerate your Bubble development

Hey Ranjit
Hope you are doing well.
Do you have any resource(article/video) for doing it through sendgrid. or can you please explain it a bit more. I tried it ,but still not able to figure out a way.

P.s-I am trying to attach a report created instantly from bubble database, not from local system or anything.

Thanks in advance

Are you familiar with the Sendgrid Mail Send API endpoint?.. if so, it’s simple enough to attach files as base 64 encoded content…

Here are their API docs: Mail Send | Twilio (sendgrid.com)

If not, there are a few Sendgrid plugins - I’d assume you can include attachments with them (I don’t use them so can’t confirm that - but it’s worth taking a look if you don’t want to make your own API calls)… even the built in Bubble Send Email action lets you attach files…

Or, are you asking more about how to create the file in the first place? Or how to schedule emails?

2 Likes

Thank you @adam
I am struggling to create a scheduler(that will run everyday at 23:00) that will create a file/download link and save that in bubble database.
Bubble’s send email only lets you allow attachment that is saved in your local DB.

*Basically I need to send a daily report to the client.The daily report contains the list of users who registered to our platform the previous day.
In bubble algorithm it will be [Search for users where created date>current date:change hours:0 and created date< current date:change hours 11:59].
So I am trying to put a scheduler that runs daily at 23:00 hrs and sends an email with the attached file(having dynamic data)

That all sounds fairly simple…

It’s still not clear from your question which part you’re having trouble with?..

But if you’re asking how to create the file, I’d definitely recommend checking out this plugin: 1T - CSV Creator Plugin | Bubble

You can use that to generate a dynamic CSV file from JSON on the backend…

Then all you need to do, is set up your workflow to run at 11pm each day, and in that workflow use the plugin action to generate the CSV file, and then attach it to the email.

The daily report contains the list of users who registered to our platform the previous day.
In bubble algorithm it will be [Search for users where created date>current date:change hours:0 and created date< current date:change hours 11:59].

By the way, this search will not give you Users who were created on the previous day…

It will give you Users who were created TODAY, but only in the morning (i.e. before 11:59am).

It’s also worth pointing out that a User’s Created date is NOT the same as the date they signed up to your App, but rather the date/time they were first created in the database - which is the very first time they landed on a page on your app (although it’s often very similar, especially if they sign up the first time they open your app, in fact it can be up to 3 days different)…

If you want to accurately record the date/time a User signed up to your app you’ll need to add a field on the User datatype to record just that.

In any case, to search for Users who signed up on the previous day, you’ll need to use the following constraints on your User search

Signed Up Date ≥ Current Date Time: Rounded Down To Day: Plus (days) -1
Signed Up Date < Current Date Time: Rounded Down To Day

1 Like

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