Fireship · @fireship

Angular 4 Transactional Email with Google Firebase Cloud Functions

Uploaded June 15, 2017 · Length 5:39

Angular 4 Transactional Email with Google Firebase Cloud Functions

Summary

Send transactional email in Angular 4 using Google Cloud Functions and Send Grid.

  • angular 4
  • transactional email
  • google cloud functions
  • send grid
  • firebase cloud functions

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    In this episode, I'm going to show you

  2. 0:02

    how to send transactional email in

  3. 0:04

    Angular 4 as a background task in the

  4. 0:07

    cloud. To facilitate this, the emails

  5. 0:10

    will be sent with Google Cloud functions

  6. 0:12

    for Firebase and the email service Send

  7. 0:15

    Grid. You can use any email provider you

  8. 0:17

    want, such as Mail Gun or Postmark or

  9. 0:20

    even Gmail, but I chose Send Grid for

  10. 0:23

    this tutorial because they have a solid

  11. 0:25

    helper library and a detailed node

  12. 0:28

    example in their documentation. They

  13. 0:30

    also offer a free trial with no credit

  14. 0:32

    card required, so you can get your API

  15. 0:34

    key and follow along without having to

  16. 0:36

    pay anything out of pocket.

  17. 0:40

    So, what is a cloud function exactly?

  18. 0:42

    Google Cloud Functions is a serverless

  19. 0:44

    architecture that allows you to run

  20. 0:46

    isolated code in a NodeJS runtime as

  21. 0:50

    opposed to deploying your own server

  22. 0:51

    from scratch. It's Google's answer to

  23. 0:54

    AWS Lambda and it's only been available

  24. 0:57

    to the public for less than a year. It's

  25. 1:00

    an awesome tool for Firebase developers

  26. 1:02

    because it allows you to run code in the

  27. 1:04

    background that would otherwise slow

  28. 1:06

    down an Angular app. And email is

  29. 1:08

    definitely one of those tasks that you

  30. 1:10

    want to delegate to its own background

  31. 1:12

    task or micro service.

  32. 1:15

    We can trigger cloud functions in many

  33. 1:17

    different ways, but this lesson will

  34. 1:19

    demonstrate the use of cloud functions

  35. 1:20

    via HTTP.

  36. 1:23

    It's also useful to know that you can

  37. 1:24

    trigger cloud functions on database

  38. 1:26

    rights, storage uploads, authentication

  39. 1:29

    events, and even analytic events, all of

  40. 1:32

    which are common use cases for

  41. 1:34

    transactional email. Some examples

  42. 1:36

    include sending a welcome email to a new

  43. 1:38

    user or sending an email when they've

  44. 1:42

    reached max capacity on file uploads or

  45. 1:45

    some other app limitation like that. I

  46. 1:47

    plan on covering these scenarios in

  47. 1:49

    future videos.

  48. 1:52

    At this point, I'm assuming you have an

  49. 1:53

    Angular app started with the Firebase

  50. 1:56

    tools package installed. Start by

  51. 1:58

    running the Firebase init command and