Python-powered Chat Apps with Twilio and SendGrid Transcripts
Chapter: Messaging and workflows with Twilio Studio
Lecture: Asking for the cake flavor

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now that we're getting the data back from the API and storing it into the variable menu, in the menu widget with its variables,
0:08 we want to have a little bit of back and forth, much like we had up here. Well, we said, Welcome what size you want.
0:14 Check the size and either say sorry that's wrong or carry on. We're going to do a similar thing down here, so we don't need this anymore.
0:26 Now we're gonna do that similar type of flow, and it's going to be a send and reply Again the name is super important. So those who we AskCakeFlavor,
0:38 then what we wanna do? They've come in. They've said they want a large cake. We've looked at the menu through the API, and we know what sizes we have.
0:45 Remember, those sizes are stored in widgets, menu, variables, for example, flavor. I think its flavor not flavours perfect.
0:56 It is so it's stored right there, and what we want to do is just ask. Here's what we have, Which one do you want?
1:04 So it's a great what flavor of cake do you want? We have that, that should work well. It's going to come along and ask them what they want.
1:15 But what we have to do now is confirm that a valid selection was made. So we'll come back and we'll do a split based on and we're also going to
1:24 have send message. But if no condition matches, we're going to send this message. And when the message is sent,
1:31 we're gonna send a background. That's our loop. That's our something went wrong. So let's connect this here and start our test.
1:38 So this will be test cake flavor in here. What do we want to put? We want to put menu.flavour like this.
1:48 Actually, it needs to be widgets again, widgets.Menu.flavour and we're going to do. There's no condition that matches will do that,
1:58 but let's go and add a condition that says MAtches Any Of, widgets.Menu.flavour
2:07 like that. So we've already got the options we've already stored into that string Remember, at once multiple values, comma, separated as a string.
2:16 That's what this is. So we should be able to just use that again, and this is not the right one.
2:22 Sorry, What we want is we want to AskCakeFlavor.inbound.body That's the message that they sent as a response. So we sent waiting for the reply.
2:35 The reply is the inbound body. Then we're going to test if any of the body was any of the things that we have as an option. Great.
2:44 We'll continue on. Let's go and just add a temporary little that worked great. Like this, good flavor like that over here,
3:00 though this is what happens if something is wrong. So we'll say wrong flavor. Say sorry. We don't have whatever this value that they asked for,
3:10 which will be AskCakeFlavor.inbound.Body widgets.AskCakeFlavor.inbound.Body Inbound body. I really think we need a small now.
3:29 Much too much cake. Alright, Vanilla perfect that's a good flavor test the other way. Large rain box. Sorry, we don't have rain box.
3:41 We have red velvet, chocolate, vanilla. How about we go for carrot this time? Perfect. That's a good flavor.
3:48 All right. So you can see we've taken this data we got from the API And we've created this little interaction we've asked them to select one of
3:54 them. As long as they get it wrong, we're just keep asking them. Let them know.
3:58 No, that's not right. Try again when they get it right and we'll moveon in our workflow


Talk Python's Mastodon Michael Kennedy's Mastodon