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