Function Store
  • Home
  • Getting started
    • Introduction
    • Installing a function
    • Reconfiguring a function
    • Uninstalling a function
    • FAQs
  • Reference
    • Requirements
      • Assign Roles
        • User permissions
      • Link a Billing account to your project
      • Enable the APIs
    • Projects
      • How to add a project
      • How to set up a project
    • Functions
      • Benefits
      • Use cases
      • Authentication when installing
      • Runtime configuration
      • Deploying with a ZIP file
    • Policies
      • How to add a Policy
      • How to remove a Policy
    • Authentication
      • Users
      • Roles
      • Permissions
    • Secrets
      • Creating a Secret
      • Using a Secret
      • Changing the value for a Secret
      • Deactivating a Secret
  • developers
    • Overview
    • Getting Started
    • Set up
    • Workspaces
      • Create a workspace
      • Workspace boilerplate
      • Node engines
    • Writing Functions
      • Function Anatomy
      • Configuration file
      • Function Triggers
      • Environment Variables
        • Type "text"
        • Type "number"
        • Type "email"
        • Type "url"
        • Type "json"
        • Type "boolean"
        • Type "select"
        • Type "multiselect"
        • Type "firestoreDocumentPath"
        • Type "firestoreCollectionPath"
        • Type "color"
      • Documentation
    • Push/Update your functions in the cloud
    • Continuous Integration
    • Publish functions in the Marketplace
    • Emulators
      • Initialize emulators in your workspace
      • Environment variables
      • Starting emulators
      • Testing your functions in the emulator
      • Importing existing data into local emulators
        • Exporting data from Cloud Firestore to local emulator
        • Exporting user accounts from Firebase to local emulator
    • Visual Studio Code Extension
      • Installing the extension
      • Extension UI
      • Functions list
      • Creating and editing functions
      • Emulators
      • Extension settings
      • Troubleshooting
        • "Command not found" error when executing a command
  • Billing
    • Understanding Billing
  • Security
    • Security
  • Resources
    • Events and Triggers
    • Best Practices
      • How to log events in functions?
    • Document your Functions
    • Editorial guidelines
    • Our Processes
      • Use Cases Analysis
  • Use cases
    • Custom Stripe Checkout
Powered by GitBook
On this page
  • Before you begin
  • The sendSignUpWelcomeEmail function
  • Step 1: Gather function parameters from SendGrid
  • Step 2: Find the sendSignUpWelcomeEmail function
  • Step 3: Select the project
  • Step 4: Install the sendSignUpWelcomeEmail function

Was this helpful?

  1. Getting started

Installing a function

This guide walks you through the steps to install a function to send a welcome email when customers sign up. You can use this example as a starting point for installing and managing functions.

PreviousIntroductionNextReconfiguring a function

Last updated 3 years ago

Was this helpful?

Before you begin

Make sure that you have the required setup for this exercise:

  • An active Google account.

  • A project in Firebase or GCP where:

    • you have to assign the following roles to a service account:

      • Cloud Function Admin

      • Firebase Authentication Admin

      • Secret Manager Admin

      • Service Account User

      • Service Usage Admin

The above list has the basic requirements to install a function, but some functions have other requirements that involve knowledge about other tools and apps.

The function selected for this example is sendSignUpWelcomeEmail. This is a free, reusable function that also requires:

  • Previous knowledge about SendGrid and Firebase.

The sendSignUpWelcomeEmail function

A welcome email is one of the first impressions your brand makes. It sets the foundation for the kind of cooperation you will have with your subscribers. The sendSignUpWelcomeEmail function will allow you to send a welcome email when users sign up via a SendGrid template.

Now you know the function, follow these steps to install it.

Step 1: Gather function parameters from SendGrid

Once you logged in to your SendGrid account, you'll need to obtain the following information to complete the installation form:

  • Find the API key to authenticate access to SendGrid services. On the rest of this page, this API key is referred to as SENDGRID_API_KEY.

  • Create a sender identity before sending an email. It’s required that you provide the identity information about where the emails are coming from in each email you send. On the rest of this page, this sender identity is referred to as SENDGRID_SENDER_EMAIL.

  • Select the template ID from a blank template, a custom template that you have already created, or a predefined SendGrid Email Design. On the rest of this page, this template ID is referred to as SENDGRID_TEMPLATE_ID.

Notice that the SendGrid template might receive the following variables depending on the provider used to signUp:

  • provider: The providerId used for signUp (google.com, facebook.com, phone, password, etc.).

  • displayName: The name of the new user created. It will be received if it's available from the provider.

  • phoneNumber: The user phone number. It will be received if it's available from the provider.

  • photoURL: The URL of the new user created. It will be received if it's available from the provider.

    These variables can be used in the template as follow:

    <p>Welcome to my company, dear {{userName}}</p>

Notice that if the user doesn't have an email associated with its account, the welcome email will not be sent.

Step 2: Find the sendSignUpWelcomeEmail function

In the Marketplace section, you'll find all the functions we created for you. Just type the name of the function in the search, scroll, or select the Free filter to easily locate the sendSignUpWelcomeEmail.

Step 3: Select the project

Now that you find it, click on the Install button. This opens a drawer with a selectable menu to choose the project where you want to install the function. Keep in mind that you must have previously set up the project.

Step 4: Install the sendSignUpWelcomeEmail function

Once you select the project, you'll need to fill out a form with the following environment variables from your SendGrid account:

  • SENDGRID_API_KEY: The API to authenticate access to SendGrid services.

  • SENDGRID_SENDER_EMAIL: Email corresponding to SendGrid sender correctly verified.

  • SENDGRID_TEMPLATE_ID: Id of SendGrid dynamic template that will be used to generate the welcome email.

Proceed to click Install, and in a few seconds, you will see the function appears in the Installed Functions section.

Great! The sendSignUpWelcomeEmail function is installed into your project and you can programmatically send welcome emails to all users who will be signing up for your project.

For more information about SendGrid, see:

you linked your project to a on GCP

you : Cloud Functions API, Cloud Build API, and Secret Manager API on the GCP. Also, you must enable for this specific type of function.

In case you want to deploy your function without granting your GCP project permissions directly in Function Store, you can do it by .

A account.

Let's say that you already have a SendGrid account: open the SendGrid page and .

For more information, check the documentation.

Find out more about our .

Billing account
uploading a ZIP file
SendGrid
sign in
SendGrid
functions
SendGrid Support
SendGrid Sending email
enabled the APIs
This video walks you through the steps to install a function to send a welcome email when customers sign up.
Firebase Authentication