如何在 Twilio Studio "Set Variables" 小部件中使用 Liquid 模板语言
How do I use Liquid template language in a Twilio Studio "Set Variables" widget
我正在使用 Twilio Studio 流程构建 SMS 机器人。我在变量值中添加了一个带有以下液体代码的 Set Variables widget:
{% capture address %}{{widgets.request_address.inbound.Body | lower | strip}}{% endcapture %}
{% if address == "yes" %}{{ flow.data.address }}{% else %}{{ widgets.request_address.inbound.Body }}{% endif %}
文档表明这应该有效:
Variables can have static values like a single number or string, or dynamic values set via the Liquid templating language.
但是代码没有被解析,而是作为字符串保存到变量中。
我错过了什么吗?不管文档怎么说,Twilio studio 是否就是不支持它?
更新:
我认为这个小部件可能只允许一个液体块。稍后在文档中说:
This can be a number or string value, or a liquid template block like the example above.
下面的代码有效(但显然输入不够灵活)
{% if widgets.request_address.inbound.Body == "yes" or widgets.request_address.inbound.Body == "Yes" %}{{ flow.data.address }}{% else %}{{ widgets.request_address.inbound.Body }}{% endif %}
嘿哟,这里是 Twilio 开发人员布道师。
我刚刚与我们的 Studio 团队核对了这个问题,您确实是对的。该小部件仅接受单个液体块。
在你的情况下,你仍然可以做的是将小部件链接在一起,并分两步执行格式化和逻辑。 :)
您看到的是第一个小部件去除空格并格式化输入,然后第二个小部件执行逻辑。
希望对您有所帮助。 :)
我正在使用 Twilio Studio 流程构建 SMS 机器人。我在变量值中添加了一个带有以下液体代码的 Set Variables widget:
{% capture address %}{{widgets.request_address.inbound.Body | lower | strip}}{% endcapture %}
{% if address == "yes" %}{{ flow.data.address }}{% else %}{{ widgets.request_address.inbound.Body }}{% endif %}
文档表明这应该有效:
Variables can have static values like a single number or string, or dynamic values set via the Liquid templating language.
但是代码没有被解析,而是作为字符串保存到变量中。
我错过了什么吗?不管文档怎么说,Twilio studio 是否就是不支持它?
更新:
我认为这个小部件可能只允许一个液体块。稍后在文档中说:
This can be a number or string value, or a liquid template block like the example above.
下面的代码有效(但显然输入不够灵活)
{% if widgets.request_address.inbound.Body == "yes" or widgets.request_address.inbound.Body == "Yes" %}{{ flow.data.address }}{% else %}{{ widgets.request_address.inbound.Body }}{% endif %}
嘿哟,这里是 Twilio 开发人员布道师。
我刚刚与我们的 Studio 团队核对了这个问题,您确实是对的。该小部件仅接受单个液体块。
在你的情况下,你仍然可以做的是将小部件链接在一起,并分两步执行格式化和逻辑。 :)
您看到的是第一个小部件去除空格并格式化输入,然后第二个小部件执行逻辑。
希望对您有所帮助。 :)