代码检查帮助:Lambda函数调用Amazon Connect API进行出站呼叫
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了代码检查帮助:Lambda函数调用Amazon Connect API进行出站呼叫相关的知识,希望对你有一定的参考价值。
(我是初学者 - 在这里寻找大师们的一些指导/指导)
我正在尝试写一个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 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)' 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 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)' 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
答案
你的错误(ContactNotFoundException
)来自connect.stopContact
电话
如果你检查connect:StopContact你可以看到当你指定的ContactNotFoundException
找不到时会发生contactId
。这意味着:
- 你有错误的
params2.ContactId
(即你试图阻止一个不存在的联系人)。 - 你有错误的
params2.InstanceId
,这意味着即使你有正确的联系人ID,它们在这个实例上也不存在。
我怀疑你有contactId
错了。如果我们看看connect:StartOutboundVoiceContact,你会看到它返回ContactId
的值。我怀疑你应该捕获这个值,然后在你的params2
对象中使用它,而不是硬编码的值。
以上是关于代码检查帮助:Lambda函数调用Amazon Connect API进行出站呼叫的主要内容,如果未能解决你的问题,请参考以下文章
Amazon Aurora Postgres 是不是支持 lambda 调用?
无法使用 Amazon Amplify 从 Lambda 调用 GraphQL