Python-powered Chat Apps with Twilio and SendGrid Transcripts
Chapter: Creating the Flask Python web app
Lecture: Posting the order to the API via Studio
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Let's jump back over to Twilio Studio. Now here's our workflow that we've been working on throughout the course.
0:08
If we go all the way down to the bottom here, remember, we got their email address,
0:14
we got their name and we are already gathered up all the details about their order And we said, Super, your order has been placed. Not really.
0:22
Why not? Really? Because we didn't have our Endpoint that we just finished billing available to send. So let's go and add that here are not using voice
0:32
I'm going to do and make an http request here. I'll call this order API. And as we saw, the method is going to be post now the domain.
0:43
I'll put something in here. Do you think that's gonna work? No we have to come back and figure out something for that.
0:52
Let's say we're going to add some JSON and let's expand this so we get some
0:55
room. What we're gonna do is we're going to construct a JSON document that's going to have customer data and the details of the cake order data.
1:05
Consider you watching me. Type that out. Let me paste something here like so and then we can have a look at it
1:10
Our overall document is going to be that there's going to be a customer with a number, name and email, and there's going to be a cake,
1:18
which is all the stuff that they filled out and then also the price that we've quoted them. So the number all of this stuff here is going to be filled
1:27
out with liquid. Let's do this one first. So we'll come over here and we'll say widgets. GetName. I believe we called it inbound.Body
1:38
body email is going to be the same. GetEmail.inbound.Body now number is interesting. We didn't ask them their number.
1:52
They sent us their number when they connected, right, That's way up at the top here, on the trigger.
2:01
So what we can do for the number is we can say trigger.message.From, So we got their number. We got the name that they've answered,
2:11
entered. We've got the email that they've entered, and we're just going to do the same thing for topping, frosting,
2:16
flavor, size and price. So when I go through all of the various widgets as cake topping, as cake frosting, as cake flavor.
2:25
Get the inbound body. That's the various answers they gave. And then we're gonna go to the size one,
2:31
which was the welcome. Their response to the welcome over here when we asked them what size do they want?
2:38
And the last one slightly slightly different here, because this comes from our other API call
2:44
Remember, we confirm the price here where we priced the cake with an http Get request. We got back and see regular widgets.PriceCake.parse.total
2:54
So that's what goes right here. Perfect. So that's the price in gold coins that we're gonna have. So everything is ready around our body.
3:09
Let's have made a mistake, which we'll find out soon enough and will fix, of the top. We still need some way to call this,
3:16
so it's not exactly going to work, But we've got everything set. As soon as we find a place to send that request to.