Amazon Connet's getCurrentMetricData is not a function

倖福魔咒の 提交于 2019-12-08 20:24:27
var AWS = require ('aws-sdk');
AWS.config.region = 'your Region';
var connect = new AWS.Connect(); 

exports.handler = (event, context, callback) => {
var AGENTS_ON_CALL_VALUE;
var dataContent = {
  CurrentMetrics: [  
    { Name: 'AGENTS_ON_CALL',
      Unit: 'COUNT'
    },
  ],
  Filters: { 
    Channels: [ 'VOICE' ],
    Queues: [ 'Your Queue ID']
  },
  InstanceId: 'Connect InstanceID',
  Groupings: [ 'QUEUE' ],
  MaxResults: 1
};

connect.getCurrentMetricData(dataContent, function(err, data) {
    var jsonstring = JSON.stringify(data);
    if (err){
        console.log(err, err.stack);
    } else{    
        var obj = JSON.parse(jsonstring);
        AGENTS_ON_CALL_VALUE = obj.MetricResults[0].Collections[0].Value;
        console.log(AGENTS_ON_CALL_VALUE);    
        callback(null,"Finish getting Data"); 
    }  
});
}

Problem Solved. Get the Newest AWS-SDK. Otherwise, it will return getCurrentMetricData is not a function error.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!