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