Fireship · @fireship
Send SMS Text Messages with Twilio and Firebase
Uploaded September 13, 2017 · Length 9:17
Summary
send text messages with twilio and firebase in angular app
- twilio
- firebase
- angular
- text messaging
- sms
- cloud functions
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
sending text messages through your app
- 0:01
can bring the user experience to the
- 0:03
next level in this lesson I have an
- 0:05
angular app where users can order a
- 0:06
pizza for delivery my goal is to update
- 0:09
the users with a text message every time
- 0:11
their order status changes so when the
- 0:13
pizza goes from cooking to on its way
- 0:15
that user gets notified directly in
- 0:17
their phone to handle the text messaging
- 0:19
we're going to use an API called Twilio
- 0:21
combined with firebase cloud functions
- 0:23
let's start by learning a little bit
- 0:25
more about Twilio from their promo video
- 0:27
Twilio is a global communications
- 0:30
platform for developers with our API and
- 0:32
a few lines of code you can add
- 0:34
messaging voice and video to your
- 0:36
applications in the programming language
- 0:38
you already use so after we sign up for
- 0:40
a Twilio account they're going to assign
- 0:42
us a phone number and we can use that
- 0:44
phone number to send text messages to
- 0:45
our users you can sign up without a
- 0:47
credit card and they'll give you a 15
- 0:49
dollar credit to experiment with the API
- 0:51
so once you've signed up make note of
- 0:54
your phone number as well as your API
- 0:56
keys which we're going to use to build
- 0:58
the firebase cloud function but before
- 1:00
we get to that point we're first going
- 1:01
to build the angular component for the
- 1:03
front-end so i've generated a new
- 1:05
component called pizza status and it's
- 1:07
going to use the reactive forms module
- 1:09
so we need to make sure to add that to
- 1:11
the import section in our ng module
- 1:13
we're using a reactive form because we
- 1:16
need to validate the phone number
- 1:17
carefully when we send it to Twilio it
- 1:19
needs to be an e 164 format which is a
- 1:22
string that looks like this the country
- 1:24
code with a plus sign followed by at the
- 1:26
full ten digit phone number so let's see
- 1:28
how we can make this possible in the
- 1:30
pizza status component we are going to
- 1:32
break the phone number down into four
- 1:33
different form inputs and then when we
- 1:35
send that data back to firebase it's
- 1:37
going to be the fully formatted II 1 64
- 1:40
string and for this lesson in firebase I
- 1:42
just have a single test order in there
- 1:44
to simulate how this could work in the
- 1:47
component itself we'll first import the
- 1:50
angularfire database as well as the
- 1:52
reactive form parts that we need then
- 1:55
we'll set a variable for the form itself
- 1:57
and set that to the type of form group
- 1:59
and then order we'll represent the data


