# ivr-tester

> An automated testing framework for IVR call flows

Latest version **0.2.12** (published 2021-06-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install ivr-tester
pnpm add ivr-tester
yarn add ivr-tester
bun add ivr-tester
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.2.12 |
| Published | 2021-06-23 |
| First published | 2020-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 10.14.2 |
| Dependencies | 6 |
| Unpacked size | 200.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 55 |
| Maintainers | sketchingdev |
| Keywords | IVR, Interactive Voice Response, call flow, call, test, telephony |

## Links

- npm: https://www.npmjs.com/package/ivr-tester
- Repository: https://github.com/SketchingDev/ivr-tester
- Homepage: https://github.com/SketchingDev/ivr-tester#ivr-tester
- Issues: https://github.com/SketchingDev/ivr-tester/issues
- npm.io page: https://npm.io/package/ivr-tester

## Dependencies (6)

- [ws](https://npm.io/package/ws.md) ^7.4.4
- [joi](https://npm.io/package/joi.md) ^17.4.0
- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [debug](https://npm.io/package/debug.md) ^4.3.1
- [twilio](https://npm.io/package/twilio.md) ^3.57.0
- [string-similarity](https://npm.io/package/string-similarity.md) ^4.0.4

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 0.2.12 (latest) — 2021-06-23
- 1.0.0-beta.0 (beta) — 2023-03-31
- 0.2.11 — 2021-06-19
- 0.2.10 — 2021-03-29
- 0.2.9 — 2021-03-19
- 0.1.8 — 2021-03-12
- 0.1.7 — 2021-03-10
- 0.1.6 — 2021-03-08
- 0.1.5 — 2021-02-26
- 0.1.4 — 2021-02-24
- 0.1.3 — 2021-01-26
- 0.1.2 — 2021-01-26
- 0.1.1 — 2021-01-25
- 0.1.0 — 2021-01-25
- 0.0.10 — 2020-11-22
- … 8 more at https://npm.io/package/ivr-tester/versions

## README

# IVR Tester

[![npm](https://img.shields.io/npm/v/ivr-tester)](https://www.npmjs.com/package/ivr-tester)
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/SketchingDev/ivr-tester.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/SketchingDev/ivr-tester/context:javascript)
![](https://github.com/SketchingDev/ivr-tester/workflows/On%20Push/badge.svg)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FSketchingDev%2Fivr-tester.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FSketchingDev%2Fivr-tester?ref=badge_shield)

<p align="center">
  Automate the testing of your IVR call flows!
</p>

IVR Tester automates the testing of IVR flows by calling them, interpreting prompts and replying with DTMF tones based
on fluent test definitions.

<p align="center">
  <img src="doc/assets/demo.gif">
</p>

Features:
* Fully automates testing call flows
* Test multiple scenarios in parallel
* Expressive test definitions help document call flow
* Record audio of tests
* Record transcriptions of tests
* Supports Google Speech-to-Text and AWS Transcript for transcribing calls
* Open-source

```typescript
const config = { transcriber: googleSpeechToText({ languageCode: "en-GB" }) };

new IvrTester(config).run(
  { from: "0123 456 789", to: "0123 123 123" },
  {
    name: "Customer is provided a menu after their account number confirmed",
    steps: [
      {
        whenPrompt: similarTo("Please enter your account number"),
        then: press("184748"),
        silenceAfterPrompt: 3000,
        timeout: 6000,
      },
      {
        whenPrompt: similarTo(
          "press 1 for booking a repair or 2 for changing your address"
        ),
        then: hangUp(),
        silenceAfterPrompt: 3000,
        timeout: 6000,
        },
     ],
  }
);
```

## Quick Start

1. [Create a Twilio account](https://www.twilio.com/referral/9E7LvU) (referral link for $10 free if you upgrade), load it with money and rent a phone number
   1. Store an [authentication token](https://support.twilio.com/hc/en-us/articles/223136027-Auth-Tokens-and-How-to-Change-Them) in environment variables:
   ```shell
   export TWILIO_ACCOUNT_SID=ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
   export TWILIO_AUTH_TOKEN=your_auth_token
   ```
1. Configure your environment for either [Google](packages/transcriber-google-speech-to-text) or [Amazon's](packages/transcriber-amazon-transcribe) transcription service
1. Install and start ngrok
   ```shell
   npm install ngrok -g
   ngrok http 8080
   ```
1. Run the tests
   ```shell
   # Local port that IVR Tester will listen on
   export LOCAL_SERVER_PORT=8080
   # URL that ngrok exposes to the outside world
   export PUBLIC_SERVER_URL=$(curl -s localhost:4040/api/tunnels | jq -r .tunnels[0].public_url)

   node test.js
   ```

## How it works

<p align="center">
  <img src="doc/assets/flow.jpg">
</p>

Under the hood this orchestrates:
 1. Establishing a bi-directional audio stream of the call to the IVR flow - using [Twilio](https://www.twilio.com/)
 1. Transcribing the voice responses from the flow - using [Google Speech-to-Text](https://cloud.google.com/speech-to-text)
 1. Using the test to conditionally respond with DTMF tones to transcripts

## Writing tests

| When         | Overview                             |
| -------------|--------------------------------------|
| [contains]   | Prompt contains a piece of text      |
| [matches]    | Prompt matches regular expression    |
| [similarTo]  | Prompt is similar to a piece of text |
| [isAnything] | Prompt can be anything               |

[contains]: ./packages/ivr-tester/doc#contains
[matches]: ./packages/ivr-tester/doc#matches
[similarTo]:  ./packages/ivr-tester/doc#similarto
[isAnything]: ./packages/ivr-tester/doc#isanything

| Then        | Overview            |
| ------------|---------------------|
| [press]     | Produces DTMF tones |
| [hangUp]    | Terminates the call |
| [doNothing] | Doesn't do anything |

[press]: ./packages/ivr-tester/doc#press
[hangUp]: ./packages/ivr-tester/doc#hangup
[doNothing]: ./packages/ivr-tester/doc#donothing

## Development

### Documentation

Where possible the documentation is generated from the code using the following script in the root directory or
individual packages:

```shell
yarn docs
```

The documentation is automatically generated and committed as part of the CI pipeline when merged to the main branch.

The official website can be previewed locally by running:

```shell
docsify serve docs
```

## License

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FSketchingDev%2Fivr-tester.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FSketchingDev%2Fivr-tester?ref=badge_large)

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