How to use the Connect function from aws-sdk

Find comprehensive JavaScript aws-sdk.Connect code examples handpicked from public code repositorys.

aws-sdk.Connect is a module in the AWS SDK for JavaScript that provides an interface for interacting with Amazon Connect, a cloud-based contact center service.

717
718
719
720
721
722
723
724
725
726
  'input[name="address.company"]:first-child',
  secretdata.company
);
await page.waitForTimeout(1000);

const connectClient = new AWS.Connect({ region: "us-east-1" });
const availablePhoneNumbers = (
  await connectClient
    .listPhoneNumbers({ InstanceId: process.env["CONNECT_INSTANCE_ID"] })
    .promise()
fork icon4
star icon30
watch icon3

+ 65 other calls in file

How does aws-sdk.Connect work?

The aws-sdk.Connect module provides a set of classes and methods that allow you to interact with Amazon Connect programmatically. You can use the module to automate common contact center tasks such as creating queues, routing incoming contacts, and retrieving metrics and reports. To use the module, you must first create an instance of the AWS.Connect class and configure it with your AWS credentials and the AWS Region where your Amazon Connect instance is located. Once you have a configured instance, you can use the methods of the class to interact with Amazon Connect. For example, you can use the createQueue method to create a new queue in Amazon Connect, or the startContactRecording method to start recording a customer interaction. You can also use the getMetricData method to retrieve metrics such as the number of calls handled by a particular queue, or the average time to answer a call. The aws-sdk.Connect module also provides a number of events that you can use to track the progress of asynchronous operations. For example, you can listen for the success event to be notified when an operation has completed successfully, or the error event to be notified when an error occurs. Overall, the aws-sdk.Connect module provides a convenient and powerful way to automate contact center tasks using JavaScript and the AWS SDK.

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const AWS = require("aws-sdk");

// Configure the AWS SDK with your credentials and region
AWS.config.update({
  accessKeyId: "your-access-key-id",
  secretAccessKey: "your-secret-access-key",
  region: "us-west-2",
});

// Create an instance of the AWS.Connect class
const connect = new AWS.Connect();

// Define the parameters for the getMetricData method
const params = {
  StartTime: new Date(Date.now() - 3600000),
  EndTime: new Date(),
  Filters: {
    Queues: ["queue-arn"],
  },
  Groupings: ["QUEUE"],
  HistoricalMetrics: [
    {
      Name: "ABANDON_TIME",
      Unit: "SECONDS",
      Statistic: "SUM",
    },
  ],
};

// Call the getMetricData method to retrieve metrics
connect.getMetricData(params, function (err, data) {
  if (err) {
    console.log(err, err.stack);
  } else {
    console.log(data);
  }
});

In this example, we first require the aws-sdk module and configure it with our AWS credentials and the AWS Region where our Amazon Connect instance is located. Next, we create an instance of the AWS.Connect class and define the parameters for the getMetricData method. The StartTime and EndTime parameters define the time range for the metrics, and the Filters parameter specifies the queue to retrieve metrics for. The Groupings parameter specifies that we want to group the metrics by queue, and the HistoricalMetrics parameter specifies the specific metric we want to retrieve (in this case, the total time that calls were abandoned). Finally, we call the getMetricData method on the connect object, passing in our parameters and a callback function to handle the response. If the operation is successful, the response data is logged to the console. If an error occurs, the error is logged to the console instead.