启用Conversations的Twilio Studio Flow发送Catalog Template报错求解决
问题:启用Conversations的Twilio Studio Flow发送Catalog Template报错
在触发端已启用Conversations的Twilio Studio Flow中尝试发送Catalog Template时,持续收到错误:Failure sending message: Unsupported Content Template Type.,由于需要集成Flex必须使用Conversations,求可行解决办法。
最小复现示例
1. 创建Content Template
{ "friendly_name": "simple_catalog", "language": "es", "types": { "twilio/catalog": { "id": "XXXXXX", // 替换为你的catalog ID "body": "Select.", "subtitle": "Subtitle", "title": "Products", "thumbnail_item_id": "id_1" // 替换为你的thumbnail ID } } }
2. 创建Studio Flow
{ "description": "A New Flow", "states": [ { "name": "Trigger", "type": "trigger", "transitions": [ { "event": "incomingMessage" }, { "event": "incomingCall" }, { "next": "send_catalog", "event": "incomingConversationMessage" }, { "event": "incomingRequest" }, { "event": "incomingParent" } ], "properties": { "offset": { "x": 0, "y": 0 } } }, { "name": "send_catalog", "type": "send-and-wait-for-reply", "transitions": [ { "next": "set_order_response", "event": "incomingMessage" }, { "event": "timeout" }, { "event": "deliveryFailure" } ], "properties": { "offset": { "x": 250, "y": 230 }, "service": "{{trigger.message.InstanceSid}}", "channel": "{{trigger.message.ChannelSid}}", "from": "{{flow.channel.address}}", "message_type": "content_template", "content_sid": "HXX",// 替换为实际的simple_catalog SID "timeout": "3600" } }, { "name": "set_order_response", "type": "set-variables", "transitions": [ { "event": "next" } ], "properties": { "variables": [ { "type": "string", "value": "{{widgets.send_catalog.inbound.Order}}", "key": "order_response" } ], "offset": { "x": 250, "y": 470 } } } ], "initial_state": "Trigger", "flags": { "allow_concurrent_calls": true } }
3. 触发报错步骤
- 向Whatsapp Sender发送消息
- 查看Flow Log执行记录,找到
send_catalog组件的deliveryFailure事件,展开后在调试信息>详情中看到错误:Failure sending message: Unsupported Content Template Type
解决办法
核心原因
Studio的send-and-wait-for-reply组件暂不支持通过Content Template发送Catalog类型消息到Conversations渠道,需要绕开该组件,直接调用Twilio Conversations API发送消息。
具体实现步骤
创建Twilio Function
编写Function调用Conversations API构造并发送Catalog消息,代码示例:exports.handler = async function(context, event, callback) { const client = context.getTwilioClient(); const { serviceSid, channelSid, catalogId, title, body, subtitle, thumbnailItemId } = event; try { const message = await client.conversations.v1.services(serviceSid) .channels(channelSid) .messages.create({ content: { "twilio/catalog": { "id": catalogId, "title": title, "body": body, "subtitle": subtitle, "thumbnail_item_id": thumbnailItemId } } }); callback(null, { success: true, messageSid: message.sid }); } catch (error) { callback(error); } };修改Studio Flow
- 删除原
send_catalog(send-and-wait-for-reply类型)组件 - 添加Run Function组件:
- 选择刚才创建的Function
- 配置输入参数:
serviceSid:{{trigger.message.InstanceSid}}channelSid:{{trigger.message.ChannelSid}}catalogId: 你的Catalog IDtitle: "Products"body: "Select."subtitle: "Subtitle"thumbnailItemId: 你的缩略图Item ID
- 添加Wait for Reply组件,监听
incomingMessage事件,后续对接原set_order_response组件逻辑
- 删除原
权限配置
确保Twilio Function拥有conversations.messages.create权限,在Function配置页面检查并添加对应权限。
验证
部署修改后的Flow和Function,重新触发测试,查看Flow Log和Conversations消息记录,确认Catalog消息成功发送,无报错。
内容的提问来源于stack exchange,提问作者Enrique
相关产品推荐
相关产品推荐

