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


Talk Python's Mastodon Michael Kennedy's Mastodon