Python-powered Chat Apps with Twilio and SendGrid Transcripts
Chapter: Messaging and workflows with Twilio Studio
Lecture: The rest of the order details
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
This pattern that you see here, ask with a send and wait for reply and then test it. If it's wrong, say sorry,
0:11
that's the wrong choice. Send them back to ask again. But if it's right, we have this condition to carry on,
0:16
which we haven't connected again. This pattern is super, super common, and we're gonna have to do it again exactly like this for the
0:24
frosting. I'm going to do it for the Topping as well. So instead of you watching me type all out these little bits,
0:29
I'm just gonna write out those and we'll review it in a moment. All right, I've repeated this pattern. Ask, Test. It is wrong.
0:39
Let them know, Go do it again. Otherwise carry on, for the three different questions that we have to interact with the three
0:46
different things we need for the cake. Now to review that. Let's hide this out of the way for a minute, so we can just see it
0:53
going. I'll go through this slowly, but I didn't want to recreate each step with you. This is exactly the same because you take a lot of time,
0:59
but I do want to fall along close enough that if you're following the video and writing the code through your studio that you can do it as well.
1:07
All right, So this one we just did together and we added the same type of thing. We're going to have another send and wait for reply to get the
1:14
frosting. And I thought it would be fun to have a little bit of information carried forward at each step. So,
1:21
for example, we're going to ask the cake frosting and say, you know, you just selected chocolate cake,
1:26
so chocolate cake sounds delicious. What frosting do you want to pair it with? We have, and then we're putting out the same string like we did for the
1:35
flavors. But now for frosting, want to test the carry on, get a response to test the frosting against the body, the inbound body of AskCakeFrosting.
1:48
And then we have two conditions. One no condition matches. Then we're going to go to wrong frosting, if it matches
1:56
any of the widgets menu. This is where we stored our variable. And remember, this is a string that is comma separated with the values,
2:03
which is exactly what we're looking for here. It's also what we need for all of our messages. So we're going to test against this,
2:09
But you can't write it like this. Remember, this is not the string that you want the variable. So you gotta use liquid to get the variable.
2:19
All right, again, if they get the wrong frosting, will say, Oh, no, We don't have whatever you ask for as frosting. Do you know one more time?
2:30
Ask with a send and wait for reply, Test, It's wrong. Let him know. Go back. Otherwise carry on. In this case, we're going to say we've got the flavor.
2:40
We've got the frosting. So let's just get that topping. So finally, let's pick a topping for your It's a chocolate cake with chocolate.
2:50
I guess the cake I put in here probably belongs. They're like that for your chocolate cake with whatever frosting. So vanilla frosting, so on.
3:03
And then we have these various toppings. This is our test. We're gonna come down here and we're gonna do the test
3:10
on the AskCakeTopping.inbound.Body or the transitions we have. If nothing matches, tell him what's wrong.
3:18
Otherwise, like before, use liquid to get the value of the menu topping variable And if it matches any of those carry on,
3:26
I finally just say onward because this is where we're going to write more code and do more interesting things with our workflow,
3:31
but we're not ready to talk about it. So let's just make sure we're running what is working here and we'll try one more time. More cake, great.
3:41
We have a bunch of cake. Well, let's keep getting small cakes because we're going to order a lot of cake Okay, so what flavor do you want?
3:47
Let's say rainbowwww. Sorry, we don't have rainbowwww. What flavor of cake? Alright, Rainbow, Rainbow cake. all we got to put a space there.
3:58
Sounds delicious. What frosting do you want to pair it with? Cream cheese? Chocolate? Vanilla? I'll say choco Oh,
4:07
no. We don't have Choco as frosting about Chocolate. There we go. Finally, let's pick a topping for your rainbow cake with chocolate
4:16
And many of those space will fix that up. We have Sprinkles, bacon, Happy birthday to be written on the top or sugar carrots. How about bacon? No.
4:28
How about lettuce? That sounds delicious, doesn't it? No. Thankfully, they don't have lettuce at the topping.
4:35
So,Bacon will be outrageous. We'll choose Bacon. Now. We've gathered up all the things of the order. The flavor, the frosting and the topping.
4:44
Onward says our workflow and onward means. Usually we start writing the rest of the code to actually start placing the order.
4:50
I feel like we've got this really cool interaction. Besides, you know the spaces I gotta fix with our chat interaction.