Skip to content

Instantly share code, notes, and snippets.

Peter Miller phmiller

Block or report user

Report or block phmiller

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@phmiller
phmiller / index.js
Last active Oct 1, 2018
Connect Current Metrics API
View index.js
const qArns = [
"arn:aws:connect:...",
"arn:aws:connect:..."
];
const metricsList = [
{
Name: "AGENTS_AVAILABLE",
Unit: "COUNT"
},
@phmiller
phmiller / index.js
Created Oct 1, 2018
Connect Contact Attributes API
View index.js
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()
@phmiller
phmiller / user.pug
Created Sep 11, 2018
Connect User API Express App - user pug view
View user.pug
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
@phmiller
phmiller / index.pug
Created Sep 11, 2018
Connect User API Express App - index pug view
View index.pug
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}
@phmiller
phmiller / index.js
Created Sep 11, 2018
Connect User API Epress App - index.js
View 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"
@phmiller
phmiller / core-snippet.js
Created Aug 21, 2018
Streams API: PR 78 - Changes to terminate method
View core-snippet.js
/**-------------------------------------------------------------------------
* 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;
@phmiller
phmiller / streamsTransfers.js
Created Jul 2, 2018
Transfers via Amazon Connect Streams API
View streamsTransfers.js
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")
}
});
@phmiller
phmiller / streamsPR64appcode.js
Created May 30, 2018
Streams PR #64 - Application Code
View streamsPR64appcode.js
// 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) {
...
@phmiller
phmiller / streamsPR64softphoneManager2.js
Created May 30, 2018
Streams PR #64 - Softphone Manager 2
View streamsPR64softphoneManager2.js
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);
}
@phmiller
phmiller / streamsPR64-softphoneManager1.js
Created May 30, 2018
Streams PR #64 - Softphone Manager 1
View streamsPR64-softphoneManager1.js
// SoftphoneManager code
connect.contact(function(contact) {
...
contact.onRefresh(function() {
...
session.remoteAudioElement = document.getElementById('remote-audio');
session.connect();
// new code
contact.session = session;
}
You can’t perform that action at this time.