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

Amazon Connect动态转接号码报错:InvalidRequestException求助

Amazon Connect动态转接报错解决

问题分析

调用StartOutboundVoiceContact API时触发InvalidRequestException,提示“Request contains attribute keys that are not valid”,但手动设置转接号码时可正常呼叫。核心矛盾在于自定义属性键的合法性或配置匹配问题。

解决方案

1. 严格遵循属性键命名规范

Amazon Connect对自定义属性键有明确要求:

  • 长度限制1-32字符
  • 仅允许字母、数字、下划线(_)、连字符(-)
  • 首字符必须是字母或数字

虽然ReminderText看似符合规范,但建议改用全小写或下划线分隔的命名(如reminder_text),避免潜在的大小写敏感或未明确的规则限制。

2. 更换非系统保留的键名

避免使用Amazon Connect的系统保留属性名(如ContactId、CustomerEndpoint等),如果不确定键名是否安全,直接更换一个完全自定义的名称测试。

3. 标准化电话号码格式

确保传入的电话号码符合E.164格式(如+91992230992),去除-这类分隔符,否则即使键名正确,也可能因值格式异常触发关联错误。

4. 同步Contact Flow与Lambda的键名配置

动态转接时,Contact Flow中引用的属性键必须与Lambda传入的键完全一致(包括大小写)。例如Lambda传入reminder_text,则Contact Flow中需选择User defined命名空间,键设为reminder_text,转接时引用${user.reminder_text}。

修改后的Lambda代码示例

connect_client = boto3.client('connect')

print(f"dst :{event['dst']}")
print(f"customer :{event['customer']}")

# 清理电话号码格式,去除分隔符并确保符合E.164规范
cleaned_customer_number = event['customer'].replace('-', '')
if not cleaned_customer_number.startswith('+'):
    cleaned_customer_number = '+91' + cleaned_customer_number  # 根据实际国家码调整

try:
    response = connect_client.start_outbound_voice_contact(
        DestinationPhoneNumber='+91' + event['dst'],
        InstanceId='---------------',
        ContactFlowId='-------------',
        SourcePhoneNumber='+815034553029',
        Attributes={
         'reminder_text': cleaned_customer_number
        }
    )

内容的提问来源于stack exchange,提问作者Nikhil Sachan

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 17:37:39