amazon-connect / amazon-connect-taskjs Goto Github PK
View Code? Open in Web Editor NEWAmazon Connect Task JS - a browser-based contact center integration API for Tasks.
License: Apache License 2.0
Amazon Connect Task JS - a browser-based contact center integration API for Tasks.
License: Apache License 2.0
Hi
I have pasted my code below. I am able to "console.log(newTask);" and get a result, however I receive an API_response error when agent.createTask is invoked. Can you please advise where I am going wrong?
Thanks
connect.agent(function(agent) {
var queuesARNs = agent.getAllQueueARNs();
agent.getEndpoints(
queuesARNs,
{
success: function(data) {
var endpoints = data.endpoints; // or data.addresses
console.log(endpoints[3]);
const newTask = {
name: "Test task from taskJS", //required, max len: 512
description: "N/A", //optional, max len: 4096
endpoint: endpoints[3],
references: { //optional
"reference name": { // string, max len: 4096
type: "URL", //required, currently only "URL" is supported as a reference type,
value: "https://www.amazon.com" //required, string, max len: 4096
}
}
};//ends newTask
console.log(newTask);
agent.createTask(newTask, {
success: function(data) { console.log("Created a task with contact id: ", data.contactId) },
failure: function(err) {console.log("error has occured");}
});//ends createTask
},//end success
failure: function(err) {
}
}//ends QueueARN
);// ends agent.getEndpoints
});//ends connect.agent
I'm aware with the https://docs.aws.amazon.com/connect/latest/APIReference/API_StartTaskContact.html API it's possible to set contact attributes, and I'm aware the streams library does not support setting contact attributes, but just wanted to confirm there's no way to set contact attributes alongside a agent.createTask operation?
Aside from contact attributes being useful for contact flow logic, they are also useful because when a telephone number is provided with a plus extension, they automatically format it as a click-to-dial, and as far as I can see that's not possible via agent.createTask references
I'm trying to use the Event handler :
taskSession.onMessage((message) => console.log("The following event has occurred:", message.ContentType))
Could you please share with code snapshot to understand how it works ?
here is my code snapshot :
c.onConnecting(function (c) { if (c.getType() === "task") { const cnn = contact.getConnections().find(cnn => cnn.getType() === connect.ConnectionType.INBOUND); if (cnn.getMediaType() === "task") { console.warn("############ TASK "); } cnn.getMediaController().then((taskSession) => { taskSession.onMessage((message) => console.log("The following event has occurred:", message.ContentType)) });
This event is only sent when agent.createTask()
is called ?
many thanks,
Alex
Hi
Im trying to run the createTask API, and I kept hitting a syntax error (missing a closing bracket). I found that this issue was fixed when I added a ',' to the references section after the 'type'
const newTask = {
name: "Test task from taskJS", //required, max len: 512
description: "N/A", //optional, max len: 4096
endpoint: endpoints,
references: { //optional
"reference name": { // string, max len: 4096
type: "URL" //required, currently only "URL" is supported as a reference type,
value: "https://www.amazon.com" //required, string, max len: 4096
}
}
};
============================
const newTask = {
name: "Test task from taskJS", //required, max len: 512
description: "N/A", //optional, max len: 4096
endpoint: endpoints,
references: { //optional
"reference name": { // string, max len: 4096
type: "URL", //required, currently only "URL" is supported as a reference type,
value: "https://www.amazon.com" //required, string, max len: 4096
}
}
};
============================
Please let me know if this correct solution, or if the original was correct and I possibly missed something else in my code.
Thanks
I am using the following code to fetch the list of task templates
**const queryParams = {/
status: 'active'
maxResults: 50
};
agent.listTaskTemplates(queryParams, {
success: function(data) { console.log("List of task templates loaded successfully", data) },
failure: function(err) {
console.error(err);
}
});**
it returns token null and empty templates array, while I have one activeTaskTemplate. I have assigned the permissions to the security profile and the same task template is displaying correctly in the CCP task window.
I am using amazon-connect-taskjs 2.0 and amazon connect streams 2.4.5
Is it possible to send a new message to a task ? Similar to how connect-chatjs works now?
createTask
does not accept an attributes
parameter like the StartTaskContact
API: https://docs.aws.amazon.com/connect/latest/APIReference/API_StartTaskContact.html
Also the above API does not accept an Endpoint
parameter to assign a task using that method.
My current use-case needs to create a task, attach attributes, and assign it to an agent, but this isn't currently possible through the API or amazon-connect-taskjs
. Is this something that could be added in the future?
createTask(taskContact: TaskContactDefinition, callbacks?: SuccessFailOptions): void;
The TypeScript typings for agent.createTask
are wrong - the optional
parameters for TaskContactDefinition
are not optional in the type definitions but the readme says that these should be:
interface TaskContactDefinition {
/** The endpoint to assign to */
readonly endpoint: Endpoint;
/** The linked contact id */
readonly previousContactId?: string;
/** The task name */
readonly name: string;
/** The task description */
readonly description: string;
/** The task references */
readonly references: ReferenceDictionary;
/** The task scheduled time */
readonly scheduledTime: number;
/** A random value */
readonly idempotencyToken: string;
}
Also the callback is:
interface SuccessFailOptions {
/** A callback that starts when the operation completes successfully. */
readonly success?: SuccessFailCallback;
/** A callback that starts when the operation has an error. */
readonly failure?: SuccessFailCallback<[string]>;
}
But success should return a contact ID like {contactId: string}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.