Python-powered chat apps with Twilio and SendGrid Transcripts
Chapter: Creating the Flask Python web app
Lecture: Call the order API from WhatsApp

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now that we've defined our OrderAPI call here.
0:03 We're going to need to go over and and put it in this order.
0:08 So we go and call it.
0:09 We'll just throw away this order placed in a minute.
0:12 Now, over here, we've got our Cloud City ngrok Endpoint,
0:16 and we still have our in ngrok running here.
0:18 So this is good. And we have our JSON body that's being passed over from
0:24 all the elements that we've gathered.
0:26 So let's make sure we save and then publish all those changes.
0:31 Now we go over to WhatsApp and we can send a message.
0:34 It may be too long since I've done this.
0:37 Remember, our sandbox only listens for a little while.
0:39 We'll say hi and we need to reconnect our sandbox.
0:43 Of course, I could have done this,
0:44 but I'd like you to see this because you're gonna run into it a bunch of
0:46 times. So let's go ahead and go over here.
0:48 And what I've done is I've gone to programmable messaging.
0:51 Try WhatsApp, and it gave me my personal code.
0:54 You use your code, not mine,
0:56 and I'm going to connect that over, great now,
1:02 We're active again. So cake me.
1:07 Let's go for a small, as you know,
1:08 we're gonna have to order many cakes throughout
1:10 this course, went out to our menu,
1:13 API. And it asked,
1:15 What are the options? And we got all those stored them in our variable.
1:18 So we're going to get a vanilla maple, sprinkles cake.
1:22 That sounds really good. It'll cost 19 gold coins.
1:25 Fantastic. Let's go for that.
1:27 Excellent. To place your order,
1:28 tell us about yourself. Not really.
1:34 Over here. What happened? Did it work?
1:37 Well, probably it's running. If we look over here,
1:40 we can see there was, in fact,
1:41 a post, and it looks like it put this as a clear string.
1:44 But that's just the encoded body the way that it got posted.
1:48 So yes, it did. Now let's do a little bit more.
1:50 Let's print out data and let's also put a breakpoint right there, that runs in the
1:57 Debugger. Now, if everything works correctly,
2:00 we should be able to actually hit a breakpoint here.
2:03 Now it may seem simple. Okay,
2:05 well, it stopped at a breakpoint,
2:06 but this is incredible. What we're doing is we're going out to the public Twilio
2:11 Cloud. We're talking to one of the workflows there.
2:14 It's orchestrating all this WhatsApp conversation,
2:16 and at the end it's going to take all the data gathered and post it back
2:20 to in ngrok in ngrok gonna funnel it over into our local flask app.
2:25 We're going to do a break point during the workflow for twilio.
2:30 Check it out and carry on that
2:31 to me, it's fantastic. All these new things coming together.
2:35 It sounds like fun. Let's try it.
2:40 Get a small vanilla cake, chocolate and Sprinkles that seems reasonable, enter our contact info
2:47 And I hit this. It should go and call our API.
2:53 Let's see what happens. Boom.
2:55 How about that? Here's our break point.
2:57 You can see we've already got some meaningful stuff up here in pycharm.
3:02 If we expand it out, you can see we've got a cake and a customer
3:04 There's all the values. There's my email address is my name the vanilla, chocolate
3:13 cake with Sprinkles Small costing 8.5.
3:16 That's it. So we've now got our data passed over correctly from Twilio Studio through
3:23 ngrok back into our flask app,
3:26 and now it's time to start building out what to do when we get some data from our WhatsApp conversation.