Cannot get the contact attributes of Amazon Connect by aws-sdk Javascript


I am using call recording on Amazon Connect.

I am trying to get the contact attribute of Amazon Connect by using the metadata value of the .wav file on S3 where the conversation was recorded.

This is my Lambda function.

Object.defineProperty(exports, "__esModule", { value: true });
const AWS = require("aws-sdk");
const connect = new AWS.Connect();
const s3 = new AWS.S3();

exports.handler = async (event, context) => {
await Promise.all( (record) => {
const bucket = event.Records[0];
const key = decodeURIComponent(event.Records[0].s3.object.key.replace(/+/g, ' '));
var params = {
Bucket: bucket,
Key: key,
const metadata = await s3.headObject(params).promise();
const contactid = metadata.Metadata['contact-id'];
const instanceid = metadata.Metadata['organization-id'];
var params = {
InitialContactId: contactid,
InstanceId: instanceid,
const connectdata = await connect.getContactAttributes(params).promise();



This is the JSON value of the .wav file (I hide my personal information).

AcceptRanges: 'bytes',
LastModified: 2021-09-01TXX:XX:XX.000Z,
ContentLength: 809644,
ContentType: 'audio/wav',
ServerSideEncryption: 'aws:kms',
Metadata: {
'aws-account-id': 'XXXXXXXXXXXX',

However, when I used Connect's getContactAttributes method using aws-sdk, there was no value in the obtained parameters.
Even though the parameter values are certainly included.




{ Attributes: {} }

The getContactAttributes method is based on this document.
And I have registered this Lambda function with an instance of Amazon Connect.

I want to know what {Attributes: {}} stands for.
Is there something wrong with the argument of the getContactAttributes method, or the output method of console.log?
In the first place, can't I get the contact attribute from the metadata of the .wav file?

There may be many mistakes because it is a beginner, but I would like advice for this.

Edited by: hagiohagi on Sep 6, 2021 11:22 PM

asked a year ago60 views
1 Answer

This problem has been self-solved.

The connect.getContactAttributes method seems to get only the value of Attributes in the contact flow. I misunderstood that it was to get the JSON itself sent from the contact flow.

I found that the value of Attributes is set by posting a key-value pair in the "Set contact attributes" block of the Amazon Connect contact flow.

answered a year 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