What can I do with Cloud Functions?

Cloud Functions gives developers access to Firebase and Google Cloud
events, along with
scalable computing power to run code in response to those events. While it's
expected that Firebase apps will use Cloud Functions in unique ways to meet
their unique requirements, typical use cases might fall into these areas:

Notify users when something interesting happens

Developers can use Cloud Functions to keep users engaged and up to date
with relevant information about an app. Consider, for example, an app that
allows users to follow one another's activities in the app. In such an app,
a function triggered by Realtime Database writes to store new followers could create
Firebase Cloud Messaging (FCM) notifications to let the appropriate users know that
they have gained new followers.

The function triggers on writes to the Realtime Database path where
followers are stored.

Other interesting notification use cases

Perform Realtime Database sanitization and maintenance

With Cloud Functions database event handling, you can modify the
Realtime Database in response to user behavior, keeping the system up to date and
clean. For example, in a chat room app built on Realtime Database, you could monitor
write events and scrub inappropriate or profane text from users' messages.
Here's how that could work:

The function's database event handler listens for write events on a specific
path, and retrieves event data containing the text of any chat messages.

The function processes the text to detect and scrub any inappropriate
language.

The function writes the updated text back to the database.

To review working code, see the Text
Moderation
sample. This sample sanitizes inappropriate language as well as uppercase
"shouting" in chat messages.

Execute intensive tasks in the cloud instead of in your app

Developers can take advantage of Cloud Functions to offload to the Google
cloud resource-intensive work (heavy CPU or networking) that wouldn't be
practical to run on a user's device. For instance, you could write a function
to listen for image uploads to Storage, download the image to the instance
running the function, modify it, and upload it back to Storage. Your
modifications could include resizing, cropping, or converting images.
ImageMagick command line tools are provided for
use with Cloud Functions to make this work easy.

A function triggers when an image file is uploaded to Storage.

The function downloads the image and creates a thumbnail version of it.

The function writes that thumbnail location to the database, so a client app can find and use it.

Other examples of batch jobs in the Firebase cloud

Integrate with third-party services and APIs

Cloud Functions can help your app work better with other services by
calling and exposing web APIs. For instance, an app used for collaboration on
development could post GitHub commits to a workgroup chat room.