代码审查帮助:Lambda函数调用Amazon Connect API进行出站调用

时间:2018-12-02 20:40:42

标签: amazon-web-services aws-lambda amazon-connect

(我是一位入门级初学者-在这里从大师那里寻找一些指针/指导)

我正在尝试编写Lambda来呼叫电话号码并启动简单的Connect呼叫流程。这是我正在尝试的代码以及我遇到的错误。有什么建议吗?

Sample Lambda Code for calling Connect API

我正在使用为呼出电话配置的默认呼出电话流(AWS内置呼叫流)

这是我执行独立的Lambda测试时遇到的错误

Response:
null

Request ID:
"e83a6066-f670-11e8-afa4-47dc77991dc5"

Function Logs:
b/sequential_executor.js:105:20)
    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)
    at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)
  message: null,
  code: 'ContactNotFoundException',
  time: 2018-12-02T20:29:04.509Z,
  requestId: 'e925d29c-f670-11e8-b5a4-53c4ecc6b5ed',
  statusCode: 410,
  retryable: false,
  retryDelay: 81.20336569510724 } 'ContactNotFoundException: null\n    at Object.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:48:27)\n    at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/rest_json.js:52:8)\n    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)\n    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10)\n    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)\n    at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)\n    at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)\n    at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10\n    at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)\n    at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)'
2018-12-02T20:29:04.666Z    e83a6066-f670-11e8-afa4-47dc77991dc5    { InvalidParameterException: ContactFlow type is invalid
    at Object.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:48:27)
    at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/rest_json.js:52:8)
    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)
    at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)
  message: 'ContactFlow type is invalid',
  code: 'InvalidParameterException',
  time: 2018-12-02T20:29:04.629Z,
  requestId: 'e92b01e8-f670-11e8-8b54-4549dfd0957e',
  statusCode: 400,
  retryable: false,
  retryDelay: 19.48408234110566 } 'InvalidParameterException: ContactFlow type is invalid\n    at Object.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:48:27)\n    at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/rest_json.js:52:8)\n    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)\n    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10)\n    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)\n    at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)\n    at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)\n    at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10\n    at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)\n    at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)'
END RequestId: e83a6066-f670-11e8-afa4-47dc77991dc5
REPORT RequestId: e83a6066-f670-11e8-afa4-47dc77991dc5  Duration: 1275.08 ms    Billed Duration: 1300 ms    Memory Size: 128 MB Max Memory Used: 33 MB  

1 个答案:

答案 0 :(得分:0)

您的错误(ContactNotFoundException)来自connect.stopContact通话

如果您选中connect:StopContact,则会发现找不到指定的ContactNotFoundException时发生contactId。这意味着:

  • 您输入了错误的params2.ContactId(即您正试图阻止不存在的联系人)。
  • 您输入的params2.InstanceId错误,这意味着即使您拥有正确的联系人ID,该联系人也不存在于此实例中。

我怀疑您错了contactId。如果我们看一下connect:StartOutboundVoiceContact,您会发现它返回 ContactId的值。我怀疑您应该捕获此值,然后在params2对象中使用它,而不是硬编码值。