Python-powered chat apps with Twilio and SendGrid Transcripts
Chapter: Messaging and workflows with Twilio Studio
Lecture: Choosing the cake size

Login or purchase this course to watch this video and the rest of the course contents.
0:00 We had our simple echo message here that just when we got a message to trigger
0:04 the workflow, we said, Hey,
0:05 thanks for your cake interest, but it's time to start building something more interesting and
0:10 more useful. What we want to do is we're going to go out and get
0:13 rid of this, because we want to do a send and wait for a reply.
0:19 Down here, we'll add our send and wait for reply,
0:21 because what we're going to do,
0:22 you wanna say, Welcome. Welcome to the cake company.
0:25 We would love to get you some cake,
0:26 but we need to know a couple of things first.
0:29 What size cake do you want?
0:31 So let's go over here. And first of all,
0:33 give us a good name. Call it welcome.
0:36 Remember, you have to use these names in programming.
0:39 These are like variable names, basically so descriptive,
0:41 but not to the enormous gonna wire up the inbound message to it again.
0:46 So when a message comes in,
0:47 it's going to do whatever this does.
0:49 It's going to say, we'll say greetings from Cloud City
0:54 Cake company. What size of cake would you like?
0:57 Now we're gonna give them some options,
0:58 and they're supposed to respond with at least one of these.
1:01 And if not, we'll tell them Well,
1:02 that's not a good choice. You got to pick one of these,
1:04 so we have a small, medium and large.
1:08 So this is the message that we're going to send over.
1:12 And if a reply comes in,
1:14 what we want to do is we want to test it.
1:17 Remember, they're going to say we have small,
1:18 medium or large. They're supposed to,
1:20 anyway, and what we need to do is check.
1:23 Do we actually have a response from them?
1:25 That makes sense. If yes, we'll carry on.
1:28 If no, there's sorry that's not the right size or type of cake.
1:33 And ask the question again. So we're going to do that with a split based
1:37 on an if statement like things.
1:39 So, if we get a reply when I come over here and say check size
1:45 in order to check the size, we have to give it a variable.
1:49 Wait a minute, variables what you type here,
1:52 maybe a type of welcome, and sure enough,
1:54 as you start to type here,
1:55 you'll see you get things that are useful.
1:58 So we could type Welcome. We want inbound .Body,
2:04 but that's a variable we're going to test.
2:06 And then we need to come over here and add a condition, if the value it
2:11 gets equal to. But it's going to be better is it matches any of, now
2:15 for multiple values. We just separate with a comma(,),
2:18 so we'll say small, medium, large.
2:22 I'm not sure about the space here,
2:23 so let's do it like this.
2:25 A small, medium, large and now it's saved and let's just send, great that works
2:31 or we're going to send them back around.
2:34 So send a message like this.
2:38 If there's a match of one of those sizes,
2:40 let's for now. Just go over here and say Great,
2:44 that's a good size. We'll fix the name in a minute as we change this
2:50 meeting of this little control here.
2:52 If it doesn't match, however,
2:54 though, let's send them another message.
2:57 And here I will say wrong size.
3:06 So we'll say Sorry, that wasn't a valid choice, like that.
3:12 Way back to the top. Here we say,
3:14 Welcome again. So comes in.
3:16 Welcome. What size? What kind of cake would you like?
3:19 We have these three sizes. We check their answer.
3:23 If it's the right size great,
3:25 that's a good size. For now,
3:27 go ahead and follow my convention.
3:29 I'm going to say this is a temp because we're not really do anything with it
3:32 yet. But we might have the wrong size,
3:35 in which case we say wrong size and we ask again.
3:37 So we'll just go in this loop until they say small,
3:39 medium or large. Let's go ahead and publish it so that we can try this
3:42 out. It's published after Whatapp we go,
3:46 I say, cake time! Greetings from Cloud City Cake Company.
3:52 What size of cake would you like?
3:54 We have small, medium and large.
3:55 I want huge cake. Sorry,
3:57 that wasn't a valid choice from the cake company.
4:00 What size would you like? We could also say that wasn't valid choice.
4:03 Please choose small, medium, large and just loop them back to ascend and wait
4:07 for reply. But I think this is okay.
4:09 Let's try Small. Great Small is a good size.
4:14 It was small, medium or large.
4:16 Fantastic. We've got this little bit of interactive exchange this back and forth in this validation, all happening over in twilio studio in our flow.