Skip to content

Commit

Permalink
Task templates APIs (#21)
Browse files Browse the repository at this point in the history
* Task templates APIs
  • Loading branch information
shishkev authored Jun 8, 2022
1 parent 05fb6b3 commit 8834c4b
Show file tree
Hide file tree
Showing 9 changed files with 12,178 additions and 24 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# CHANGELOG.md

## 2.0.0
Added functions:
* `agent.updateContact` method to update a task contact created from a template.
* `agent.listTaskTemplates` method to load a list of task templates that belong to a connect instance.
* `agent.getTaskTemplate` method to load a template data, including fields, default values and constraints.

Other changes:
* `agent.createTask` method supports new parameteres and allows to create templated tasks. See README.md for more details.
* `connect.ReferenceType` new reference types supported.
91 changes: 86 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ $ git clone https://github.com/amazon-connect/amazon-connect-taskjs

[Amazon Connect Streams](https://github.com/aws/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](https://nodejs.org)
2. Checkout this package into workspace and navigate to root folder
Expand Down Expand Up @@ -120,12 +122,29 @@ Create a new task.
const newTask = {
name: "string", //required, max len: 512
description: "string", //optional, max len: 4096
endpoint: endpointObject, //required, can be retrieved via `agent.getEndpoints()`. Agent and queue endpoints supported.
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
"reference name": { // string, max len: 4096
type: "URL", //required, currently only "URL" is supported as a reference type,
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: "example@abc.com" //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: "example@abc.com" //required, string, max len: 4096
}
},
scheduledTime: "number" //optional, UTC timestamp in seconds when the task should be delivered.
Expand All @@ -135,13 +154,75 @@ 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.

```js
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

```js

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

```js

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 there is only one reference type, URL.
This enumeration lists the different reference types for a task. Currently supported types: URL, EMAIL, NUMBER, STRING, DATE.

* `ReferenceType.URL`: A URL reference.

Expand Down
2 changes: 1 addition & 1 deletion dist/amazon-connect-task.js

Large diffs are not rendered by default.

Loading

0 comments on commit 8834c4b

Please sign in to comment.