# @jlafer/twilio-helpers

> My collection of helpers for using the Twilio NodeJS SDK

Latest version **1.0.12** (published 2021-10-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jlafer/twilio-helpers
pnpm add @jlafer/twilio-helpers
yarn add @jlafer/twilio-helpers
bun add @jlafer/twilio-helpers
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2021-10-16 |
| First published | 2019-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=8.2.0 |
| Dependencies | 5 |
| Unpacked size | 48.1 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Author | jlafer |
| Maintainers | jlafer |
| Keywords | twilio |

## Links

- npm: https://www.npmjs.com/package/@jlafer/twilio-helpers
- npm.io page: https://npm.io/package/@jlafer/twilio-helpers

## Dependencies (5)

- [axios](https://npm.io/package/axios.md) ^0.23.0
- [ramda](https://npm.io/package/ramda.md) ^0.26.1
- [dotenv](https://npm.io/package/dotenv.md) ^7.0.0
- [twilio](https://npm.io/package/twilio.md) ^3.30.1
- [fngraph](https://npm.io/package/fngraph.md) 0.0.8

## Recent versions

- 1.0.12 (latest) — 2021-10-16
- 1.0.11 — 2021-10-15
- 1.0.10 — 2021-10-15
- 1.0.9 — 2020-03-29
- 1.0.8 — 2020-03-28
- 1.0.7 — 2020-02-14
- 1.0.6 — 2019-12-27
- 1.0.5 — 2019-12-27
- 1.0.4 — 2019-12-27
- 1.0.3 — 2019-12-27
- 1.0.2 — 2019-05-06
- 1.0.1 — 2019-04-20
- 1.0.0 — 2019-04-20

## README

# jlafer/twilio-helpers

This is my collection of utility functions that I find useful in Twilio projects.

## Installation

    npm install --save @jlafer/twilio-helpers

## Helper Functions

### getClient
```
getClient(accountSid, authToken)
```
Returns a NodeJS Twilio SDK client.

### getFlexConfig
```
getFlexConfig :: (accountSID, authToken) -> Promise
```
Returns a Promise that, on success, resolves to the Flex service configuration object.

### getFlexConfigProps
```
getFlexConfigProps :: (accountSID, authToken, keys) -> Promise
```
Returns a Promise that, on success, resolves to the properties with the selected keys from the Flex service configuration object.

### getFlexConfigAttributes
```
getFlexConfigAttributes :: (accountSID, authToken) -> Promise
```
Returns a Promise that, on success, resolves to the `attributes` property from the Flex service configuration object.

### getFlexPluginAttributes
```
getFlexPluginAttributes :: (accountSID, authToken, namespace) -> Promise
```
Returns a Promise that, on success, resolves to the property having the selected namespace within the `attributes` property of the Flex service configuration object.

### updateFlexConfig
```
updateFlexConfig :: (accountSID, authToken, newCfg) -> Promise
```
Asynchronously updates the Flex service configuration object.
WARNING: this is a destructive `put` operation -- not a patch. For every key supplied in `newCfg`, all desired final data for that key must be supplied. Use `getFlexConfig` to retrieve the entire service configuration object.

### updateFlexAttributes
```
updateFlexAttributes :: (accountSID, authToken, newAttributes) -> Promise
```
Asynchronously updates the `attributes` property within the Flex service configuration object.
WARNING: this is a destructive `put` operation -- not a patch. For every key supplied in `newCfg`, all desired final data for that key must be supplied. Use `getFlexConfigAttributes` to retrieve the entire `attributes` property`.

### updateFlexPluginAttributes
```
updateFlexAttributes :: (accountSID, authToken, namespace, pluginData) -> Promise
```
Asynchronously updates a single plugin namespace within the `attributes` property of the Flex service configuration object. The `pluginData` object will be merged into the `attributes` property using the `namespace` value as the key. In this way, other subkeys of `attributes` will be left unchanged.

### patchFlexConfigKey
```
patchFlexConfigKey :: (accountSID, authToken, key, patchObj) -> Promise
```
Asynchronously patches the property with the specified `key` in the Flex service configuration object, using data in `patchObj`. The `patchObj` data will be merged into the property with the specified key. In this way, any subkeys of `key` not specified in `patchObj` will be left unchanged.

### deleteFlexPluginAttributes
```
deleteFlexPluginAttributes :: (accountSID, authToken, namespace) -> Promise
```
Asynchronously deletes a single plugin namespace from within the `attributes` property of the Flex service configuration object.

### formatWorkspace
```
formatWorkspace(workspace)
```
Formats the key properties of the argument.
### logWorkspace
```
logWorkspace(workspace)
```
Logs the key properties of the argument to the console.
### getWorkspaces
```
getWorkspaces(client)
```
Returns all TaskRouter workspaces for the project.
### getWorkspace
```
getWorkspace(client, sid)
```
Returns a TaskRouter workspace by its SID.

### getWorkspaceByName
```
getWorkspaceByName(client, name)
```
Returns a TaskRouter workspace by its name.

### formatActivity
```
formatActivity(activity)
```
Formats the key properties of the argument.
### logActivity
```
logActivity(activity)
```
Logs the key properties of the argument to the console.
### getActivities
```
getActivities(client, wrkspcSid)
```
Returns all TaskRouter activities for the project.
### getActivity
```
getActivity(client, wrkspcSid, sid)
```
Returns a TaskRouter activity by its SID.
### getActivityByName
```
getActivityByName(client, wrkspcSid, name)
```
Returns a TaskRouter activity by its name.

### formatWorkflow
```
formatWorkflow(workspace)
```
Formats the key properties of the argument.
### logWorkflow
```
logWorkflow(workspace)
```
Logs the key properties of the argument to the console.
### getWorkflows
```
getWorkflows(client, wrkspcSid)
```
Returns all TaskRouter workspaces for the project.
### getWorkflow
```
getWorkflow(client, wrkspcSid, sid)
```
Returns a TaskRouter workspace by its SID.
### getWorkflowByName
```
getWorkflowByName(client, wrkspcSid, name)
```
Returns a TaskRouter workspace by its name.

### formatEvent
```
formatEvent(event)
```
Formats the key properties of the argument.
### logEvent
```
logEvent(event)
```
Logs the key properties of the argument to the console.
### getEvents
```
getEvents(client, wrkspcSid)
```
Returns all TaskRouter events for the workspace identified by the argument.
NOTE: currently, no date range or other limits are placed on this call, so it's only suitable for use in a small test workspace.
### formatTask
```
formatTask(task)
```
Formats the key properties of the argument.
### logTask
```
logTask(task)
```
Logs the key properties of the argument to the console.
### getTasks
```
getTasks(client, wrkspcSid)
```
Returns all TaskRouter tasks for the workspace identified by the argument.
NOTE: currently, no filters are placed on this call so it's only suitable for use in a small test workspace.
### getTask
```
getTask(client, wrkspcSid, taskSid)
```
Returns a TaskRouter task for the workspace and task SID identified by the arguments.
### createTask
```
createTask(client, wrkspcSid, data)
```
Creates a new TaskRouter task in the workspace identified by the argument. The data object can include properties such as workflowSid, taskChannel, priority and attributes.
### updateTask
```
updateTask(client, wrkspcSid, taskSid, data)
```
Updates a TaskRouter task. The data object can include properties assignmentStatus, reason, priority and attributes.
### formatExecution
```
formatExecution(execution)
```
Formats the key properties of the argument.
### logExecution
```
logExecution(execution)
```
Logs the key properties of the argument to the console.
### getExecutions
```
getExecutions(client, flowSid, fromDt, toDt)
```
Returns a Promise that resolves to an array of objects with two properties: `execution` and `context`. The array will contain all Studio executions for the Workflow identified by `flowSid` within the date-time range defined by `fromDt` and `toDt`. Dates are specified with strings in ISO 8601 format.
### getExecutionsPage
```
getExecutionsPage(client, flowSid, param)
```
Returns a Promise that resolves to one page of Studio executions for the Workflow identified by `flowSid`. It returns an object with two properties: `execContexts` and `nextPageUrl`. `execContexts` is an array of objects with two properties: `execution` and `context`.

To retrieve the first page of data, `param` should contain an object with list filtering properties (e.g., `fromDt`, `toDt`, `pageSize`). Dates are specified with strings in ISO 8601 format. If `nextPageUrl` in the result is non-null, the next page of data can be retrieved by passing it as the `param` value.
### getExecution
```
getExecution(client, flowSid, execSid)
```
Returns a Studio execution for the Workflow identified by `flowSid` and execution identified by `execSid`.
### getExecContext
```
getExecContext(client, flowSid, execSid)
```
Returns the execution context for the Studio Workflow identified by `flowSid` and execution identified by `execSid`.

---
_Source: https://npm.io/package/@jlafer/twilio-helpers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
