Skip to content

Latest commit

 

History

History
152 lines (104 loc) · 4.94 KB

README.md

File metadata and controls

152 lines (104 loc) · 4.94 KB

actions-nodejs-typescript

Table Of Contents

Pre-requisites

  • Node.js 22.X
  • A Callr account
  • A Callr API key

Installation

Please create an .env file with the following content:

CALLR_API_KEY=your-callr-api-key

You may create API keys from https://app.callr.com/api/keys.

Then run:

npm install
npm run build
npm run ping

It should output something like this:

$ npm run build && npm run ping

> [email protected] build
> tsc


> [email protected] ping
> node dist/ping.js

PING OK, timestamp: 1735562976

Usage

List your current numbers

This will list your first 50 numbers, with their assigned scenarios:

npm run list-numbers

List your scenarios

npm run list-scenarios

Delete a scenario

npm run delete-scenario [scenario-id]

Remove a phone number from your account

npm run remove-number [number-id]

Create a new scenario (call forwarding with recording enabled)

This will create a new Actions scenario that forwards calls to a target phone number, specified as a command line argument. The "template" scenario is available in src/scenarios/forwarding-record.yaml.

# npm run create-scenario-target [phone-target]
npm run create-scenario-target +1234567890

This will output the scenario ID:

> [email protected] build
> rm -fr dist/* && tsc


> [email protected] create-scenario-target
> node dist/create-scenario-target.js +1234567890

┌─────────┬────────────┬──────────────────────────────────┬───────────────────────┐
│ (index) │ id         │ name                             │ created               │
├─────────┼────────────┼──────────────────────────────────┼───────────────────────┤
│ 0       │ '3TXTPS65' │ 'Call Forwarding to +1234567890' │ '2024-12-30 15:24:22' │
└─────────┴────────────┴──────────────────────────────────┴───────────────────────┘

Take note of the scenario ID, it will be required later.

Buy a new phone number

npm run buy-number [area-code-id]

You may use the API method did/areacode.get_list to get the area code IDs.

This will buy a French +331 phone number:

npm run buy-number 1

> [email protected] build
> rm -fr dist/* && tsc


> [email protected] buy-number
> node dist/buy-number.js 1

┌─────────┬────────────────────────────────────────────┬────────────┬────────────────┐
│ (index) │ token                                      │ id         │ number         │
├─────────┼────────────────────────────────────────────┼────────────┼────────────────┤
│ 0       │ '1DRXUfFGXfHiriY0hWBmsq6QKMk8mwmahNQOyYqM''LXLGRVDT''+33186611221' │
└─────────┴────────────────────────────────────────────┴────────────┴────────────────┘

You may now run attach-number-to-scenario.js

Attach the new number to the previously created scenario

# npm run attach-number-to-scenario [number-id] [scenario-id]
npm run attach-number-to-scenario LXLGRVDT 3TXTPS65
                                  ^^^^^^^^ ^^^^^^^^
                                   number  scenario

Now, you may call the new number, and it will forward the call to the target phone number. You can access the Actions logs from the Callr dashboard: https://app.callr.com/logs/actions.