通过Zapier实现ManyChat图库卡片自动化遇JSON解析错误求助
解决ManyChat动态消息Zapier模块报错:Cannot read properties of undefined (reading 'errors')
问题重现
开发Instagram DM自动化功能,通过Zapier从Wix商店拉取产品数据,经Code by Zapier模块转换为ManyChat动态消息要求的JSON格式,使用ManyChat模块的「发送动态消息」操作时,无论用官方示例JSON还是自定义JSON,均触发错误:Cannot read properties of undefined (reading 'errors')
排查与解决步骤
1. 确认JSON字段映射正确性
这个报错最常见的原因是JSON没有传入ManyChat模块的指定字段。检查Zapier中ManyChat模块的参数,确保你把Code模块输出的JSON直接映射到Dynamic Block JSON字段,而非其他无关参数。
2. 保证Code模块输出为纯JSON对象
如果Code by Zapier模块返回的是字符串形式的JSON,会导致ManyChat模块解析失败。修改Code模块代码,确保输出是JSON对象而非字符串:
// 生成符合格式的动态消息对象 const dynamicMessage = { "version": "v2", "content": { "type": "instagram", "messages": [ { "type": "cards", "elements": [ { "title": "Card title", "subtitle": "card text", "image_url": "https://manybot-thumbnails.s3.eu-central-1.amazonaws.com/ca/xxxxxxzzzzzzzzz.png", "action_url": "https://manychat.com", "buttons": [] } ], "image_aspect_ratio": "horizontal" } ], "actions": [], "quick_replies": [] } }; // 返回对象类型的输出 return { dynamicMessage };
之后在Zapier中把Code模块的dynamicMessage字段映射到ManyChat的Dynamic Block JSON参数。
3. 验证用户ID与权限
- 确认传入的用户ID是ManyChat识别的有效Instagram用户ID,而非其他平台的ID(比如Wix用户ID),可以从ManyChat后台复制测试用户ID进行验证。
- 检查Zapier绑定的ManyChat账号是否拥有Instagram DM的发送权限,确保账号未被限制。
4. 改用Webhook直接调用ManyChat API(备选方案)
如果Zapier的ManyChat模块持续报错,可以绕过模块,直接用Zapier的Webhook模块调用ManyChat API:
- 请求URL:
https://api.manychat.com/fb/sending/sendDynamicMessage - 请求方法:POST
- 请求头:
Authorization: Bearer 你的ManyChat API令牌Content-Type: application/json
- 请求体:
{ "user_id": "目标Instagram用户ID", "block": { "version": "v2", "content": { "type": "instagram", "messages": [ { "type": "cards", "elements": [ { "title": "Card title", "subtitle": "card text", "image_url": "https://manybot-thumbnails.s3.eu-central-1.amazonaws.com/ca/xxxxxxzzzzzzzzz.png", "action_url": "https://manychat.com", "buttons": [] } ], "image_aspect_ratio": "horizontal" } ], "actions": [], "quick_replies": [] } } }
这种方式能直接获取API返回的详细错误信息,更易定位问题。
内容的提问来源于stack exchange,提问作者Faizan Ul Haq
相关产品推荐
相关产品推荐

