Send a new user a custom video with their username inserted into video and poster when they signup.

DanielPerley Member Posts: 3
edited January 2023 in Developer APIs

Hey everyone, here is the function I made to help utilize Cloudinary's on the fly transformation capabilities to send a new user an email with a custom video personalized with their username.

If you already know the ropes and are familiar with firebase functions, you can skip right to the point and checkout the repo here:

The function is triggered when the user's profile info is added to the users collection in firebase, and uses an email template and a separate function which triggers an email when a document is added to the collection specified when you set up the built-in firebase "trigger email" function, which triggers an email to be sent by Sendgrid or any email service you configure it to use.

So, to be clear. The prerequisites for using this function are:

Install and configure the firebase "trigger email" extension.

Create an email template specifically to be used for sending welcome email, where the header image of the email can be inserted dynamically. Give the template a name, and make sure the html feild contains the handlebar brackets as placeholders for {{username}}, {{imageUrl}}, and {{videoUrl}}, or whatever you decide to use as placeholders. The videoUrl will be the link attached to a button for them to view the video.

Signup for a cloudinary account and upload a video to be used as the video background. Then, use the cloudinary GUI to lay a text overlay over the video, which the function will replace with the user's name. Note the entire string which will need replaced, because you will specify that string in the function code. I used "New%20User" (the %20 becomes a space).

Copy the entire url and specify it as the value of the dynamicVideoUrl in the function.

Customize the functions replaceMentString with the value of the username in your database.

Deploy to firebase and test.

In my example, it will also send them a new email when they change their username, in case they want to share it with their current username.

In my opinion, this is a great way to show your users your app goes the extra mile to create a valuable experience for them. It is also a great way to get them to share your app!

This is only a small example of how Cloudinary can be used to really make your app speci. Much more can be done, and I will try to share my journey with you all as I continue to build.

Let me know if you have any questions about the email template.

Thanks for reading this!