Skip to content

Instantly share code, notes, and snippets.

View phm200's full-sized avatar

Peter Miller phm200

View GitHub Profile
@phm200
phm200 / index.js
Last active October 1, 2018 19:49
Connect Current Metrics API
const qArns = [
"arn:aws:connect:...",
"arn:aws:connect:..."
];
const metricsList = [
{
Name: "AGENTS_AVAILABLE",
Unit: "COUNT"
},
@phm200
phm200 / index.js
Created October 1, 2018 19:32
Connect Contact Attributes API
app.post("/submit-updateAttributes", async (req, res) => {
const contactId = req.body.contactId;
const flagForFollowUpRaw = req.body.flagForFollowUp; // will equal "on" if checked, undefined if false
const flagForFollowUp = flagForFollowUpRaw && flagForFollowUpRaw === "on";
var updateContactAttributesParams = {
InstanceId: connectInstanceId,
InitialContactId: contactId,
Attributes: {
FlaggedForFollowUp: flagForFollowUp.toString()
@phm200
phm200 / user.pug
Created September 11, 2018 21:18
Connect User API Express App - user pug view
html
head
title= title
link(rel="stylesheet" href="../css/base.css")
body
h2= "Details for " + user.Username
ul
li= "ARN: " + user.Arn
li= "First Name: " + user.IdentityInfo.FirstName
li= "Last Name: " + user.IdentityInfo.LastName
@phm200
phm200 / index.pug
Created September 11, 2018 21:17
Connect User API Express App - index pug view
html
head
title= title
link(rel="stylesheet" href="css/base.css")
body
h2= "Users in my Connect Instance (" + dataList.length + ")"
ul
each val in dataList
li
a(href="user/" + val.Id) #{val.Username}
@phm200
phm200 / index.js
Created September 11, 2018 21:16
Connect User API Epress App - index.js
const express = require("express");
const app = express();
const AWS = require("aws-sdk");
require("express-async-errors");
const connectInstanceId = "7f03...";
var connectClient = new AWS.Connect({
apiVersion: "2017-08-08",
region: "us-east-1"
@phm200
phm200 / core-snippet.js
Created August 21, 2018 14:29
Streams API: PR 78 - Changes to terminate method
/**-------------------------------------------------------------------------
* Uninitialize Connect.
*/
connect.core.terminate = function() {
connect.core.client = new connect.NullClient();
connect.core.masterClient = new connect.NullClient();
var bus = connect.core.getEventBus();
if(bus) bus.unsubscribeAll();
connect.core.bus = new connect.EventBus();
connect.core.agentDataProvider = null;
@phm200
phm200 / streamsTransfers.js
Created July 2, 2018 17:43
Transfers via Amazon Connect Streams API
var agent = new lily.Agent();
agent.getEndpoints(agent.getAllQueueARNs(), {
success: function(data){
console.log("valid_queue_phone_agent_endpoints", data.endpoints, "You can transfer the call to any of these endpoints");
},
failure:function(){
console.log("failed")
}
});
@phm200
phm200 / streamsPR64appcode.js
Created May 30, 2018 19:54
Streams PR #64 - Application Code
// api.js
Contact.prototype.onSession = function(f) {
var bus = connect.core.getEventBus();
bus.subscribe(this.getEventName(connect.ContactEvents.SESSION), f);
};
...
// application code
function subscribeToContactEvents(contact) {
...
@phm200
phm200 / streamsPR64softphoneManager2.js
Created May 30, 2018 19:53
Streams PR #64 - Softphone Manager 2
connect.contact(function(contact) {
...
contact.onRefresh(function() {
...
session.remoteAudioElement = document.getElementById('remote-audio');
session.connect();
// new code
var bus = connect.core.getEventBus();
bus.trigger(contact.getEventName(connect.ContactEvents.SESSION), session);
}
@phm200
phm200 / streamsPR64-softphoneManager1.js
Created May 30, 2018 19:52
Streams PR #64 - Softphone Manager 1
// SoftphoneManager code
connect.contact(function(contact) {
...
contact.onRefresh(function() {
...
session.remoteAudioElement = document.getElementById('remote-audio');
session.connect();
// new code
contact.session = session;
}