npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

amazon-connect-taskjs

v2.0.0

Published

Provides task support to AmazonConnect customers

Downloads

29,404

Readme

AmazonConnectTaskJS

About

The Amazon Connect Task javascript library (TaskJS) gives you the power to handle task contacts when used together with Amazon Connect Streams.

Learn More

To learn more about Amazon Connect and its capabilities, please check out the Amazon Connect User Guide.

Getting Started

Using TaskJS from Github

$ git clone https://github.com/amazon-connect/amazon-connect-taskjs

Including TaskJS

Amazon Connect Streams is required to use TaskJS. Ensure you import TaskJS after Streams.

TaskJs v2.0 requires Streams v2.2 or later.

Building

  1. Install latest LTS version of NodeJS
  2. Checkout this package into workspace and navigate to root folder
  3. npm install
  4. To build (non-minified):
    1. npm run devo for a non-minified build.
    2. Find build artifacts in dist directory.
  5. To build (minified):
    1. npm run release for a minified build.
    2. Find build artifacts in dist directory.
  6. To run unit tests:
    1. npm run test
  7. To clean node_modules:
    1. npm run clean
  8. To make webpack watch all files:
    1. npm run watch

Find build artifacts in dist directory - This will generate a file called amazon-connect-task.js - this is the full Connect TaskJS API which you will want to include in your page.

Usage:

TaskJS provides a taskSession instance for each task contact. You can access the taskSession by calling the getMediaController method on a taskConnection. getMediaController returns a promise that resolves with a taskSession instance.

For example:

taskConnection.getMediaController().then((taskSession) => { /* ... */ });

Event Handlers

Each of the following event handlers will pass a message object to the callback function containing the following fields:

  • AbsoluteTime: UTC timestamp of when the event occurred.
  • ContentType: One of the following strings depending on the event:
    • application/vnd.amazonaws.connect.event.transfer.initiated
    • application/vnd.amazonaws.connect.event.transfer.succeeded
    • application/vnd.amazonaws.connect.event.transfer.failed
    • application/vnd.amazonaws.connect.event.expire.warning
    • application/vnd.amazonaws.connect.event.expire.complete
  • Id: The contact ID
  • InitialContactId: The initial contact id.

taskSession.onTransferInitiated

Subscribe a method to be invoked when the server has initiated the task transfer.

taskSession.onTransferInitiated((message) => console.log("Transfer has initiated"))

taskSession.onTransferSucceeded

Subscribe a method to be invoked when the task transfer has succeeded.

taskSession.onTransferSucceeded((message) => console.log("Transfer has succeeded"))

taskSession.onTransferFailed

Subscribe a method to be invoked when the task transfer has failed.

taskSession.onTransferFailed((message) => console.log("Transfer has failed"))

taskSession.onTaskExpiring

Subscribe a method to be invoked two hours before the task expires.

taskSession.onTaskExpiring((message) => console.log("Task will expire in two hours"))

taskSession.onTaskExpired

Subscribe a method to be invoked when the task has expired.

taskSession.onTaskExpired((message) => console.log("Task has expired"))

taskSession.onMessage

Subscribe a method to be invoked when any one of the above events has occurred.

taskSession.onMessage((message) => console.log("The following event has occurred:", message.ContentType))

Methods

agent.createTask()

Create a new task.

const newTask = {
    name: "string", //required, max len: 512
    description: "string", //optional, max len: 4096
    endpoint: endpointObject, //required for non templated tasks, can be retrieved via `agent.getEndpoints()`. Agent and queue endpoints supported.
    taskTemplateId: "string", //required for templated tasks, ID of the template the task is created from. Template should belong to connect instance
    previousContactId: "string", //optional, the previous contact ID for a linked task
    references: { //optional. Only URL references are supported for non templated tasks
    	"reference name 1": { // string, max len: 4096
    		type: "URL" //required, string, one of connect.ReferenceType types, 
    		value: "https://www.amazon.com" //required, string, max len: 4096
    	},
        "reference name 2": { // string, max len: 4096
    		type: "EMAIL" //required, string, one of connect.ReferenceType types
    		value: "[email protected]" //required, string, max len: 4096
    	},	
        "reference name 3": { // string, max len: 4096
    		type: "NUMBER" //required, one of connect.ReferenceType types
    		value: 1000 //required, number
    	},
        "reference name 4": { // string, max len: 4096
            type: "DATE", //required, string, one of connect.ReferenceType types
            value: 1649961230 //required, number
        },
        "reference name 5": { // string, max len: 4096
    		type: "STRING" //required, string, one of connect.ReferenceType types
    		value: "[email protected]" //required, string, max len: 4096
    	}	
    },
    scheduledTime: "number" //optional, UTC timestamp in seconds when the task should be delivered.
};

agent.createTask(newTask, {
	success: function(data) { console.log("Created a task with contact id: ", data.contactId) },
	failure: function(err) { /* ... */ }
});

agent.updateContact()

Update a task contact created from a template.

const updatedTaskData = {
    contactId: "string", // required, task contact identifier
    name:  "string", // optional, task name
    description: "string", // optional, task description
    references: { //optional, used to specify updated template fields
        "reference name": { // string
    		type: "NUMBER" //required, one of connect.ReferenceType types
    		value: 1001 //required, number
    	}
        //see more examples in agent.createTask() description
    }
};

agent.updateContact(updatedTaskData, {
	success: function() { console.log("The task updated successfully") },
	failure: function(err) { /* ... */ }
});

agent.listTaskTemplates()

Load a list of task templates that belong to a connect instance


const queryParams = {// required
    status: 'active', //optional, string, can be either 'active' or 'inactive'
    maxResults: 50 //optional, number, max value of 100
};

agent.listTaskTemplates(queryParams, {
	success: function(data) { console.log("List of task templates loaded successfully", data) },
	failure: function(err) { /* ... */ }
});

agent.getTaskTemplate()

Load a template data, including fields, default values and constraints


const templateParams = {// required
    id: 'string', //required, string, template ID, template should belong to connect instance
    version: 'string' //optional, string, task template version
};

agent.getTaskTemplate(templateParams, {
	success: function(data) { console.log("Template data loaded successfully", templateParams.id, data) },
	failure: function(err) { /* ... */ }
});

Enumerations

connect.ReferenceType

This enumeration lists the different reference types for a task. Currently supported types: URL, EMAIL, NUMBER, STRING, DATE.

  • ReferenceType.URL: A URL reference.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.