Python-powered chat apps with Twilio and SendGrid Transcripts
Chapter: Sending outbound text messages
Lecture: WhatsApp API keys

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now, in order to work with the Twilio messaging service,
0:03 we're going to use the Twilio project.
0:05 No surprise there. So over on it's just twilio We're just going
0:10 to pip install twilio. And of course,
0:13 the thing that we're going to need to do to use it is to create the
0:16 REST client. That's fine. But here we go.
0:19 This is the part with our secrets.
0:21 We need to set the account and the token.
0:25 Well, where do we get those from?
0:27 Much like we did with send grid.
0:28 We need a safe place to store them.
0:30 But let me show you first where to go and find yours.
0:34 We go to our project and we go here and click settings and go to our
0:37 general settings. We've got an account SID.
0:40 But more importantly, if you scroll down,
0:43 not going to click it. But here,
0:44 behind this little section is our auth token.
0:49 So this is our SID.
0:51 And then here's our actual token that we're going to use.
0:53 Do you want to get your version of this token and put it somewhere safe?
0:58 We already have a place for that,
1:00 right? over here, we have our secrets which are not opening and its golden
1:07 because it's not stored in git.
1:09 But we have our template. And for our template,
1:11 we're going to have something like we had before.
1:14 Twilio, is want to put our SID and AUTH token in here
1:17 And of course, say"TODO: Set in secrets.json,
1:25 Just like before. We don't get the value here.
1:28 This is just a template to help us make sure we can recreate it successfully.
1:33 You go set in your secrets.json
1:34 I've already just now done that.
1:37 Of course not recording. And the last thing we got to do is go load
1:40 it just like we did before.
1:42 So even over in our app,
1:43 we have configured secrets. A little bit more is happening.
1:46 So we're already verifying that we can load up this secrets.json
1:49 and we want to go over and have not just in our secrets,
1:54 not just the send grid name.
1:56 We're going to have twilio _sid.
2:02 Which is going to be one of those.
2:03 And twilio_key, which looks like that as well.
2:08 You want to set those two things and here will say it.
2:12 twilio_keys. Then let's look at our template.
2:19 What we call them 'sid' and auth_token.
2:22 So there's the 'sid' and our auth_token.
2:34 Let's make sure we just run this.
2:36 Everything hangs together. Yeah, it looks like we were able to read those out
2:41 just fine. Again. Don't really want to look at them because they're secret,
2:45 But we'll get that all set up.
2:48 Well, when I want to go and import our app secrets,
2:52 we also need to use twilio. So let's just go out and throw twilio in here
2:55 Click Install, pip install-Our requirements.txt take your pick and then we'll
3:07 say from import client.
3:13 We'll start by saying our client here is going to be one of these clients that
3:16 we create. What we can do is just set the username and the password here
3:20 and the username is going to be app_secrets.twilio_sid
3:25 And the password can be app_secret.twilio_key, All right,
3:32 that's going to create our client that we're ultimately going to use to send our WhatsApp
3:36 message. Let's just make sure one more time that we can call this and this
3:42 all gets set up just correctly.
3:43 So we'll go over here, go to the admin section to fulfill one more of
3:49 these things. Perfect. We still haven't actually sent the message.
3:52 There's a little bit more to explore to make that happen,
3:54 but it looks like we're able to create the client,
3:56 get the private security keys and so on and get that all set up and ready to go.