Amazon Connect call progress tracking - node.js

I am currently working on a project, one of the elements of which is Amazon Connect. So far I have the function of triggering the connection locally on the disk and according to the documentation I am using the following code.
const AWS = require('aws-sdk');
AWS.config.loadFromPath('./configuration/keys/key-aws.json');
exports.makeCall = (number) => {
let connect = new AWS.Connect();
var params = {
InstanceId: 'xxxxxx',
ContactFlowId: 'xxxxxx',
SourcePhoneNumber: 'xxxxxx',
DestinationPhoneNumber: number,
Attributes: {},
};
connect.startOutboundVoiceContact(
params,
function(error, response) {
if (error) {
console.log(error)
callback('Error', null);
} else {
console.log('Initiated an outbound call with Contact Id ' + JSON.stringify(response.ContactId));
}
}
);
};
My questions about this:
Is it possible to track the call status (in progress / completed / rejected), because in the above solution we only get information that the connection has been initiated, and we only have ContactId in the response.
Is it possible to use a custom function in Amazon connect without using AWS Lamda, but an external source (eg App engine from GCP).
Is it possible to create a solution where I can make another call only after finishing the first one?
Thanks in advance for your help!

There are a couple of options here. You could call DecribeContact and check the DisconnectTimestamp and the ConnectedToAgentTimestamp this can tell you if the call is still in progress and if it got to an agent, therfore if it got answered. However you'd have to keep calling this function to track the call.
The other option involves using the kinesis data stream and monitoring that to track the contact and calling the lamba when the contact completes. See https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html
I would be writing the contactid to a dynamodb and using that in the lambda that watches the kinesis stream.
Do you mean from within a contact flow? If so then not directly, you can only call lambdas, but the lambda could call the external source.
Sure, either using the DecribeContact call as above Or, if you send the outbound call to a queue that only has a single agent associated with it (via a Routing Profile or using an Agent Queue) the you could use GetCurrentMetricData and check the AGENTS_AVAILABLE and CONTACTS_IN_QUEUE metrics to decide whether to create a new call.

why don't you use amazon streams API? you will get the call statuses in every single event. e.g. OnConnecting, OnConnected, OnMissed & OnCompleted.

Related

How can I get all envelopes status and their signers status in one request?

Is it possible to call the DocuSign API with the "docusign-client"-library in order to get status information about all envelopes with all of their recipients/signers in one request?
When we call the "EnvelopesApi.ListStatusAsync" method of the docusign client library we just retrieve an array of envelopes but without the status information of their signees.
public async Task<EnvelopesInformation> GetListStatus(EnvelopeIdsRequest envelopeIds, ListStatusOptions opt) {
return await Request(async api => await api.ListStatusAsync(settings.AccountId, envelopeIds, opt));
}
It seems that this information have to be determine in second request by calling
"EnvelopesApi.ListRecipientsAsync" method for every envelope.
Maybe someone have an idea or know how to call the API properly.
Are there any options we have to consider by calling the API or do we need to configure something in the DocuSign dashboard?
Thanks!
Remarks: In our environment we can't use webhooks. So we have to poll the DocuSign API.
No, it's not possible and maybe we should understand your statement about "we can't use webhooks".
My guess is that you have firewall or some private network and you can't have calls from outside into these servers. That's not a reason not to use webhooks.
There's a simple solution to this involving an intermediary cloud account that gets your webhooks and a queue mechanism for you to check for messages.
Here is a blog post by Larry that can help if you are willing to consider webhooks.
Yes, you're right. The main reason why we can't use webhooks is because the applicationn is behind a firewall and our customer do not want to make any changes on that.
Also I know the possibility of using DouSign with services like Azure or AWS to get notification about their bus-messaging system but this is something we do not want to implement yet. Maybe in the future.
We found out that we can use the "EnvelopesApi.ListStatusChangesAsync" method to get all of the status information we're interested in.
var options = new ListStatusChangesOptions {
envelopeIds = ids,
include = "recipients"
};
var result = await client.ListStatusChangesAsync(options);

How to send client Call sid to newly transferred agent using Twilio node.js library without using Database

I'm working on a conference call scenario and want to transfer live call from one agent to other agent. When I transfer the call is there any method that I could use to send the Conference Name, ConferenceSid and client Call Sid to new agent. as response.send() sends values to existing client. Is there any method we can use to send these parameters to new agent? The API used is as follows.
client.conferences(conferences.sid)
.participants
.create({
from: '+183xxxxxxxxx',
to: `client:${agentNumber}`
})
.then(participant => console.log(participant));
Twilio developer evangelist here.
In this cold transfer scenario you already have the conference sid, as you show in your code. So, to find the conference name you can use the REST API to look it up.
client.conferences(conference.sid)
.fetch()
.then(conference => console.log(conference.friendlyName));
You can also fetch the conference participants. One of the call sids will be the call you created to your agent and the other will be the caller that is already on the line.
client.conferences('CFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
.participants
.list()
.then(participants => {
participants.forEach(participant => console.log(participant.callSid));
});
Using these two API calls you can get the information for your new agent.
Let me know if this helps at all.

Node.js Azure sdk - getting the Virtual Machine state

I've started to look into the azure sdk for node.js (link below) and interestingly enough I've hit a wall in what I'd image would be one of the most common tasks one would want to achieve using Azure's REST endpoints which is checking the status of a virtual machine.
I can easily get a list of all machine, or one in particular but the response from this services don't include the current status of the VM (running,stopped etc.)
There's absolutely no info out there regarding this particular scenario in the docos or the web other than a blog post (https://github.com/Azure/azure-xplat-cli/issues/2565) which is actually in regards of a different library.
Please not that I'm using the azure-arm-compute library which is part of the Node.js azure sdk.
Any help would be very much appreciated
github repo: https://github.com/Azure/azure-sdk-for-node
To get Virtual Machine statuses, please use function get(resourceGroupName, vmName, optionsopt, optionalCallbackopt), and pass the vaule {expand: 'instanceView'} as the options parameter.
var msRestAzure = require('ms-rest-azure');
var computeManagementClient = require('azure-arm-compute');
// Interactive Login
// It provides a url and code that needs to be copied and pasted in a browser and authenticated over there. If successful,
// the user will get a DeviceTokenCredentials object.
msRestAzure.interactiveLogin(function(err, credentials) {
var client = new computeManagementClient(credentials, 'ed0caab7***');
client.virtualMachines.get('<resourceGroupName>', '<vmName>', {expand: 'instanceView'}, function(err, result, request, response) {
if (err) console.log(err);
console.log(result.instanceView);
});
});

Getting customized message from GCM using Web push notifications

I'm using Web push notifications with Chrome, and they work great. But now I want to deliver a custom message in my notifications. I can have my Service Worker call out to my site to get content, as is done at https://simple-push-demo.appspot.com/—which is fine if I want every recipient to see the same message.
Is there any way to get either the recipient’s registration_id or the message_id that GCM returns? If I could get either of these and include them in the callback to the service, I could customize the response.
Also, any info on when we might be able to include a payload in the call to GCM?
The registration_id and message_id fields aren't exposed, but if the user is previously authenticated to your app, any fetch() to the server from your Service Worker will include credentials (and session information) which you can use to identify them.
If that doesn't work for your case, you can store user/session information in IndexedDB.
Payloads are coming soon—likely Chrome 50 or 51—based on the Web Push protocol. It's a bit of extra overhead and work to configure the (required) encryption.
It's possible, but I wouldn't do it since it's specific to GCM, while other browsers use other services.
You can either create a unique ID for each user (like we're doing in Mercurius) and store it in IndexedDB, or you can use the entire endpoint URL as an ID.
Here's the snippet to get the registration_id:
self.registration.pushManager.getSubscription()
.then(function(subscription) {
if (subscription) {
var endpoint = subscription.endpoint;
var endpointParts = endpoint.split('/');
var gcmRegistrationID = endpointParts[endpointParts.length - 1];
console.log(gcmRegistrationID);
}
});
P.S.: It returns a promise, so make sure your service worker waits for the promise to be resolved.

Paypal: Transaction History with REST API / Nodejs SDK

I would like to display all the inbound/outbound transactions a user made/received to display it in a simple html list.
I'm using the recommended node.js module https://github.com/paypal/rest-api-sdk-nodejs and I'm trying to use this code to get the transactions:
// Get Transaction History
paypal.payment.list({
'count': 100,
'sort_by':'create_time',
'sort_order': 'asc',
'start_time': '2008-03-06T11:00:00Z'
}, function(error, payment_history){
if(error){
console.error('error', error);
response.data.payment_history = {};
} else {
console.log('history', payment_history);
response.data.payment_history = payment_history;
}
response.finish();
});
but payment_history gives me { count: 0 }. I'm pretty sure that I have transactions since 2008.
I'm not really sure what's the problem. The user is already logged in using the access_token and I can display user informations but I have no idea how to pull transaction informations.
Look into https://developer.paypal.com/docs/faq/#general-developer-questions for the answer to "Can I retrieve the history of transactions created using the Classic APIs using the REST API?".
I also ran into this issue. Strangely, It seems that the PayPal REST API only returns results for payments made through the REST API. See here: https://stackoverflow.com/a/18139747
Classic API will remain the way to do this until the REST API is improved.

Resources