0

I am using Amazon Connect Streams API [https://github.com/amazon-connect/amazon-connect-streams/blob/master/Documentation.md] and we have different call status in Amazon Connect e.g. call connected, call missed/no answered!

how can i get call status of the following call dispositions (busy, connected, in progress, ringing, no answered) from within Streams API?

I am using

function subscribeToContactEvents(contact) {
console.log("Subscribing to events for contact");
contact.onMissed(handleOnMissed);
contact.onConnected(handleOnConnected);
contact.onEnded(handleOnEnded);
}

function handleOnMissed(contact){
    console.log("[contact.onMissed] Call is Missed. Contact status is " + contact.getStatus().type);
}

function handleOnConnected(contact) {
    console.log("[contact.onConnected] Call is ACW. Contact status is " + contact.getStatus().type);
}

function handleOnEnded(contact) {
console.log("[contact.onEnded] Call has ended. Contact status is " + contact.getStatus().type);
}
Abdul Qayyum
  • 104
  • 1
  • 8

1 Answers1

1

There are two steps to this, first you need to subscribe to agent events then you trigger based on things happening to the agent. So for example...

connect.agent(async function (agent) {
    agent.onStateChange(function (agentState){
        console.log("Agent State Changed to: " + agentState.newState);
    });
});

You can do similar subscribing to contact events.

connect.contact(function (contact) {
    activeContact = contact;
    contact.onRefresh(function (contact) {/* do stuff */});
    contact.onIncoming(function (contact) {/* do stuff */});
    contact.onAccepted(function (contact) {/* do stuff */});
    contact.onMissed(function (contact) {/* do stuff */});
});

Subscribing to events is covered here... https://github.com/amazon-connect/amazon-connect-streams/blob/master/Documentation.md#event-subscription

ledge
  • 359
  • 1
  • 6
  • contact.onMissed(); gives error as well as contact.onEnded. console prints, "contact.onMissed Call is Missed. Contact status is error" on function handleMissed(contact) { console.log("contact.onMissed Call Missed by agent. Call status is " + contact.getStatus().type); } – Abdul Qayyum Apr 21 '22 at 07:47
  • Without seeing the full code you are using it is hard to tell what is going wrong here. I am using similar code to my example above without issues. – ledge Apr 22 '22 at 22:04
  • i have added the code in question. please guide me as where i am missing the logic. – Abdul Qayyum May 06 '22 at 12:05
  • Ah, I think I see the issue. Although you can have a function for onMissed and onEnded, as soon as those events occur the contact object is destroyed, so you'll get an error when you call contact.getStatus().type as there is no contact object to get the type for. I don't think there is any way to get the contact status once that contact object has been deleted. – ledge May 08 '22 at 08:32
  • I am able to get the Call End & Connected status with the same method. – Abdul Qayyum May 09 '22 at 15:19