Twilio 轮播模板,其中包含有关操作的动态内容

问题描述 投票:0回答:1

我正在尝试使用 Content API 在 Twilio 中为 WhatsApp 实现轮播模板。在我在卡片的操作中包含像

{{1}}
这样的 Twilio 变量之前,实现效果很好。下面是我的方法的 JSON 示例:

{
    "friendly_name": "carousel_template",
    "language": "en",
    "types": {
        "twilio/carousel": {
            "body": "Here are some Items that may interest you!",
            "cards": [
                {
                    "title": "{{1}}",
                    "body": "{{2}}",
                    "media": "{{3}}",
                    "actions": [
                        {
                            "type": "QUICK_REPLY",
                            "title": "{{4}}",
                            "id": "{{5}}"
                        },
                        {
                            "type": "URL",
                            "title": "{{6}}",
                            "url": "{{7}}"
                        }
                    ]
                },
                {
                    "title": "{{8}}",
                    "body": "{{9}}",
                    "media": "{{10}}",
                    "actions": [
                        {
                            "type": "QUICK_REPLY",
                            "title": "{{11}}",
                            "id": "{{12}}"
                        },
                        {
                            "type": "URL",
                            "title": "{{13}}",
                            "url": "{{14}}"
                        }
                    ]
                }
            ]
        }
    }
}

当我尝试通过 API 创建模板时,遇到以下错误:

  1. 按钮标题文本不能包含表情符号或以下字符:[_*~{} ]
  2. 无效的 URL,未使用 HTTPS 或 HTTP 协议

这些错误表明在这种情况下使用 Twilio 变量可能不可行。有没有人成功实施了类似的设置,或者有人可以帮助我找出问题吗?

twilio twilio-api
1个回答
0
投票

虽然我无法将操作标题设置为变量,但我成功解决了 URL 的问题。事实证明,使用类似于

https://www.baseurl.com/{{1}}
的基本 URL 效果非常好。这个方法使我能够部分制作动态网址。

为了确保模板得到 WhatsApp 的批准,建议在 JSON 中添加示例变量:

{
    "friendly_name": "carousel_template",
    "language": "en",
    "variables": {
        "1": "additional/url/filename.jpg",
        "2": "additional/url",
        "3": "additional/url/filename.jpg",
        "4": "additional/url"
    },
    "types": {
        "twilio/carousel": {
            "body": "Here are some Items that may interest you!",
            "cards": [
                {
                    "title": "some title",
                    "body": "some body",
                    "media": "https://www.baseurl.com/{{1}}",
                    "actions": [
                        {
                            "type": "URL",
                            "title": "Check out on our webpage",
                            "url": "https://www.baseurl.com/{{2}}"
                        }
                    ]
                },
                {
                    "title": "some title",
                    "body": "some body",
                    "media": "https://www.baseurl.com/{{3}}",
                    "actions": [
                        {
                            "type": "URL",
                            "title": "Check out on our webpage",
                            "url": "https://www.baseurl.com/{{4}}"
                        }
                    ]
                }
            ]
        }
    }
}  
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.