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 from these various widgets that we've dragged onto the flow.
0:10 And in fact, it's not just saying the name of something, but there's complex and interesting transforms that you might want to make.
0:17 For example, if we call the Web service and we get an array of things back, we might want to put them into a string that says, we have these
0:23 options x,y,z. Which one would you like? Those types of transformations require more than just saying the name of an array or something like that.
0:33 The flows use the liquid template language. The liquid template language is pretty similar to what you might consider something like a Jinja
0:43 template from flask or chameleon or Django template, one of those types of things,
0:47 maybe even a little bit more like a JavaScript front end framework way of talking about
0:52 variables. And so over here you can see you have the documentation over on twilio about this language, but stuff within double {{.
1:01 You can put markup within early percent. You want to just take a variable and turn it into a string within a larger
1:09 string. You can say something like Hello, {{name}} or traverse a variable relationship like we did with our welcome.inbound.body
1:21 so we can work with variables. We can work with dictionaries that we get back and we can use them at in this dictionary style. But more likely,
1:28 you would like, just treat them like an object like this. There's also this idea of filters.
1:33 If I'm going to take some variable and make a change to it, maybe I want to capitalize it or format it as a date or divide it or
1:40 something. The thing that's going to be really interesting for us is join. When I spoke about, I got a list of things back from an API
1:47 I want to show it to the user. The way we're going to do that is take that list and join. It was, say, the string, space.
1:53 So it goes. Item one, space item two, space, item three, space and so on. So this is not a complex programming language,
2:02 not a lot of things going on that we're going to use here.
2:05 But this liquid templating language is really important for transforming and testing this data that
2:11 we might be working with both from API's and from the user.

Talk Python's Mastodon Michael Kennedy's Mastodon