You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何借助Conversations API将WhatsApp定位数据接入Twilio Studio Flow

问题:Twilio Studio Flow处理WhatsApp定位消息的配置异常

我正尝试在Twilio Studio Flow中获取WhatsApp消息的入站定位数据,但Conversations API不支持直接处理该功能,需要额外配置,目前遇到了以下问题:

已完成的前置配置

  • 将WhatsApp发送者的消息通过Default Messaging Service for Conversations路由至Twilio无服务器函数/wa/webhook
  • 该函数会解析入站定位数据,以application/geo+json媒体类型通过Media API上传为GeoJSON,并将包含媒体SID的解析消息添加至对话,示例GeoJSON如下:
{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [
      19.18691444397,
      -34.418468475342
    ]
  },
  "properties": {
    "address": "1 Taute Street, Hermanus, Western Cape 7200",
    "label": "Mountain View Manor Guesthouse"
  }
}

异常情况说明

向Twilio号码发送单条消息时,根据参与者的配置方式,会出现两种不符合预期的结果:

  1. 对话transcript中出现{unparsed:inbound, parsed:inbound, outbound1, outbound2}消息:未解析的原始消息和解析后的消息均触发了Studio Flow,导致重复触发(Webhook创建后的初始消息未在示例中复现)
  2. transcript中仅出现{parsed:inbound, outbound}消息:符合消息展示预期,但Studio Flow发送的出站消息无法通过WhatsApp回发给原发送者

两种参与者配置示例

配置方式1:使用address与addressProxy(文档推荐)

该配置会触发上述第一种异常情况,代码示例:

const participant = await client.conversations.v1
  .conversations(conversation.sid)
  .participants.create({
    xTwilioWebhookEnabled: 'true',
    'messagingBinding.address': event.From,
    'messagingBinding.proxyAddress': event.To,
    attributes: JSON.stringify({ ProfileName: event.ProfileName }),
  })

配置方式2:使用identity

该配置会触发上述第二种异常情况,代码示例:

const participant = await client.conversations.v1
  .conversations(conversation.sid)
  .participants.create({
    xTwilioWebhookEnabled: 'true',
    identity: event.From,
    attributes: JSON.stringify({ ProfileName: event.ProfileName }),
  })

当前Webhook配置

const webhook = await conversation.webhooks().create({
  target: 'studio',
  'configuration.filters': ['onMessageAdded'],
  'configuration.flowSid': context.FLOW_SID, 
})

需求

希望实现解析后的入站消息能与Studio Flow正确交互,且出站消息可正常回发给原发送者。

*附:我更倾向使用Incoming Conversation触发器而非Incoming Message,但可能不得不转向后者并手动捕获每个出站组件的回复。

内容的提问来源于stack exchange,提问作者Geoffrey Garrett

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 07:17:56