Search code examples
node.jsamazon-web-servicesgoogle-cloud-platformamazon-connect

Amazon Connect call progress tracking


I am currently working on a project, one of the elements of which is Amazon Connect. So far I have the function of triggering the connection locally on the disk and according to the documentation I am using the following code.

const AWS = require('aws-sdk');
AWS.config.loadFromPath('./configuration/keys/key-aws.json');

exports.makeCall = (number) => {
    let connect = new AWS.Connect();
    var params = {
        InstanceId: 'xxxxxx',
        ContactFlowId: 'xxxxxx',
        SourcePhoneNumber: 'xxxxxx',
        DestinationPhoneNumber: number,
        Attributes: {},
    };

connect.startOutboundVoiceContact(
    params,
    function(error, response) {

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

};

My questions about this:

  1. Is it possible to track the call status (in progress / completed / rejected), because in the above solution we only get information that the connection has been initiated, and we only have ContactId in the response.
  2. Is it possible to use a custom function in Amazon connect without using AWS Lamda, but an external source (eg App engine from GCP).
  3. Is it possible to create a solution where I can make another call only after finishing the first one?

Thanks in advance for your help!


Solution

    1. There are a couple of options here. You could call DecribeContact and check the DisconnectTimestamp and the ConnectedToAgentTimestamp this can tell you if the call is still in progress and if it got to an agent, therfore if it got answered. However you'd have to keep calling this function to track the call.

    The other option involves using the kinesis data stream and monitoring that to track the contact and calling the lamba when the contact completes. See https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html

    I would be writing the contactid to a dynamodb and using that in the lambda that watches the kinesis stream.

    1. Do you mean from within a contact flow? If so then not directly, you can only call lambdas, but the lambda could call the external source.

    2. Sure, either using the DecribeContact call as above Or, if you send the outbound call to a queue that only has a single agent associated with it (via a Routing Profile or using an Agent Queue) the you could use GetCurrentMetricData and check the AGENTS_AVAILABLE and CONTACTS_IN_QUEUE metrics to decide whether to create a new call.