Python-powered chat apps with Twilio and SendGrid Transcripts
Chapter: Messaging and workflows with Twilio Studio
Lecture: Liquid templating language

Login or purchase this course to watch this video and the rest of the course contents.
0:00 You saw in our split based on control, that we could refer to variables or properties
0:06 from these various widgets that we've dragged onto the flow.
0:09 And in fact, it's not just saying the name of something,
0:12 but there's complex and interesting transforms that you might want to make.
0:16 For example, if we call the Web service and we get an array of things
0:19 back, we might want to put them into a string that says, we have these
0:22 options x,y,z.
0:25 Which one would you like? Those types of transformations require more than just saying the
0:30 name of an array or something like that.
0:32 The flows use the liquid template language.
0:36 The liquid template language is pretty similar to what you might consider something like a Jinja
0:42 template from flask or chameleon or Django template,
0:45 one of those types of things,
0:46 maybe even a little bit more like a JavaScript front end framework way of talking about
0:51 variables. And so over here you can see you have the documentation over on twilio
0:56 about this language, but stuff within double {{.
1:00 You can put markup within early percent.
1:04 You want to just take a variable and turn it into a string within a larger
1:08 string. You can say something like Hello,
1:09 {{name}}
1:11 or traverse a variable relationship like we did with our welcome.inbound.body
1:20 so we can work with variables.
1:21 We can work with dictionaries that we get back and we can use them at in
1:25 this dictionary style. But more likely,
1:27 you would like, just treat them like an object like this.
1:30 There's also this idea of filters.
1:32 If I'm going to take some variable and make a change to it,
1:35 maybe I want to capitalize it or format it as a date or divide it or
1:39 something. The thing that's going to be really interesting for us is join.
1:43 When I spoke about, I got a list of things back from an API
1:46 I want to show it to the user.
1:48 The way we're going to do that is take that list and join.
1:50 It was, say, the string, space.
1:52 So it goes. Item one, space item two, space, item three,
1:56 space and so on. So this is not a complex programming language,
2:01 not a lot of things going on that we're going to use here.
2:04 But this liquid templating language is really important for transforming and testing this data that
2:10 we might be working with both from API's and from the user.