By using AWS re:Post, you agree to the Terms of Use
/Instead of Outbound Calling It is making Inbound Calling while using StartOutboundVoiceContact API!/

Instead of Outbound Calling It is making Inbound Calling while using StartOutboundVoiceContact API!

0

I am using StartOutboundVoiceContact API to make automate outbound calls, i have assigned permission of StartOutboundVoiceContact to lambda role and than configure the parameters as below:

const AWS = require('aws-sdk');
AWS.config.update({ region: 'us-east-1' });

exports.handler = (event, context, callback) => {
    let connect = new AWS.Connect();
    const customerName = event.name;
    const customerPhoneNumber = event.number;
    
    let params = {
        "InstanceId" : '8XXXefXX-18XX-4XXf-bXXf-328XXXX8fXX4',
        "ContactFlowId" : 'XX59XXXf-XXXe-4XX6-XX5d-5XXd7XXX1XX1',
        //"SourcePhoneNumber" : '+18XXX675XXX',
        "QueueId": '7dXXXX19-XXXX-450f-XXXX-XXXXaf1dfXXX',
        "DestinationPhoneNumber" : customerPhoneNumber,
        "Attributes" : {
            'name' : customerName,
        }
    }
    
    connect.startOutboundVoiceContact(
        params, function (error, response){
            
            if(error) {
                console.log(error, error.stack)
                callback("Error", null);
            } else
            {
                console.log('Initiated an outbound call with Contact Id ' + JSON.stringify(response.ContactId));
                callback(null, 'Success');
            }
        }
        );

and testing with test event:

{
  "name": "Abdul",
  "number": "+18XXX749XXX"
}

It does initiating a call but from Destination to Source instead of Source to Destination. I have used an outbound flow but than it gives me the error of Invalid Contactflow Typ/Id.

1 Answers
0

Hello,

Thank you for reaching out to us . I have implemented your code in my local with few more changes and could able to successfully initiate outbound calling. Please find the code below :

const AWS = require('aws-sdk');

AWS.config.update({ region: 'us-east-1' });

exports.handler = (event, context, callback) => {

let connect = new AWS.Connect();

const customerName = event.name;

const customerPhoneNumber = event.number;

let params = {

    "InstanceId" : 'xxxxxxx-7f52-4d2f-992d-xxxxxxx',

    "ContactFlowId" : 'xxxxxx-5afb-428e-bbae-xxxxxx',

    "DestinationPhoneNumber" : customerPhoneNumber,

    "SourcePhoneNumber" : "+1xxxxxxxx",

    "Attributes" : {

        'name' : customerName,

    }

}

connect.startOutboundVoiceContact(

    params, function (error, response){
        
        if(error) {

            console.log(error, error.stack)

            callback("Error", null);

        } 
       else
        {
            console.log('Initiated an outbound call with Contact Id ' + JSON.stringify(response.ContactId));
            callback(null, 'Success');
        }
    }
    );

}

Test Event - { "name": "Namratha",

"number": "+1xxxxxxxx" }

CLI Command. -

aws connect start-outbound-voice-contact --region us-east-1 --destination-phone-number +1xxxxxxxxxx --contact-flow-id 1b3xx98ab0-xxxxxx-428e-bbae-xxxxxxx --instance-id d56bce38-7f52-4d2f-xxxxx-xxxxxx --source-phone-number +1xxxxxxxxx

Destination number and source number needs to be provided to the command to execute outbound calling. Please refer to this document for more information on outbound calling [1] .

References:

  1. https://docs.aws.amazon.com/cli/latest/reference/connect/start-outbound-voice-contact.html
SUPPORT ENGINEER
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions