'How to update agent status from lambda function
I am working on Amazon Connect application. I am using lambda for handling backend data. My requirement is to change agent status from lambda call using AWS SDK/Stream API. I know we can do this from Amazon Connect stream api via CCP. But in my case, it needs to be done from lambda call. I checked documentation of AWS Connect SDK but there is not direct method available for changing Agent state.
Kindly suggest.
Thanks, gans
Solution 1:[1]
You can directly set the agent state using the Amazon Connect Streams API:
var state = agent.getAgentStates()[0];
agent.setState(state, {
success: function() { /* ... */ },
failure: function(err) { /* ... */ }
});
Reference: https://github.com/amazon-connect/amazon-connect-streams/blob/master/Documentation.md#agent-api
Solution 2:[2]
The April 2022 Connect release has added an API call to do this finally!
There is now a PutUserStatus operation that will update a given agents status.
The call to the operation in javascript is:
const AWS = require('aws-sdk');
const connect = new AWS.Connect();
let params = {
AgentStatusId: 'STRING_VALUE', /* required */
InstanceId: 'STRING_VALUE', /* required */
UserId: 'STRING_VALUE' /* required */
};
connect.putUserStatus(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
where:
UserId is the guid identifier of the user.
InstanceId is the guid identifier of the Amazon Connect instance.
AgentStatusId — the guid identifier of the agent status. This can be retrieved via the listAgentStatuses operation.
More info here:
https://docs.aws.amazon.com/connect/latest/APIReference/API_PutUserStatus.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Dennis Traub |
Solution 2 |