1
votes

(I'm a rank beginner - looking for some pointers/guidance from the gurus here)

I am trying to write a Lambda to call a Phone number and initiate a simple Connect call-flow. Here is the code I am trying and errors I am getting. Any suggestions?

Sample Lambda Code for calling Connect API

I am using a Default Outbound Callflow (AWS built in callflow) configured for outbound call

Here is the error I am getting when I do a standalone Lambda test

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
Did you solved this issue? I've the same...pedro.olimpio

1 Answers

1
votes

Your error (ContactNotFoundException) is coming from the connect.stopContact call

If you check connect:StopContact you can see that a ContactNotFoundException occurs when the contactId you've specified can't be found. Which means either:

  • You have the wrong params2.ContactId (i.e. you're trying to stop a contact that does not exist).
  • You have the wrong params2.InstanceId which means that even if you have the right contact id, they don't exist on this instance.

I suspect you've got contactId wrong. If we take a look at connect:StartOutboundVoiceContact you'll see that it returns the value of ContactId. I suspect that you should be capturing this value, and then using it in your params2 object, rather than the hardcoded value.