Skip to content

Commit

Permalink
feat: First commit for OS
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Hartzell committed Jun 29, 2023
1 parent 6c5859c commit e84db72
Show file tree
Hide file tree
Showing 46 changed files with 10,775 additions and 27 deletions.
37 changes: 37 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = {
extends: [
'plugin:prettier/recommended',
'plugin:security/recommended',
],
plugins: [
'html'
],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
rules: {
'prefer-const': 'error',
'react/prop-types': 'off',
'react/display-name': 'off',
'security/detect-object-injection': 'off',
'no-unused-vars': 2,
'no-undef': 2,
'prettier/prettier': 'off',
'semi': 2
},
globals: {
Cypress: true,
RED: true,
$: true
},
env: {
'amd': true,
'node': true,
'es6': true,
'jest': true,
}
};
33 changes: 33 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
19 changes: 19 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

name: release-please

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
with:
release-type: node
package-name: "@sinch/node-red-voice-api"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.DS_Store
.vscode

15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Contributing to @sinch/node-red-voice-api
All contributions are welcome. Here are some guidelines you must follow.

### Raising an issue
Raise the issue on the project's issue tracker and make sure that the issue hasn't been raised before.
Try to be as clear as possible in the description of your issue.
Include what Node-RED version and node.js version you're running.
Also, if possible, include a small example flow that can be used to reproduce the issue.

### Feature request
For now, features are requested by raising an issue on the project.

### Pull request
For pull-requests, make sure that the commit message follows the [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/) specification.
If the pull-request relates to an issue, also include the issue number (#issuenumber) in the commit message.
29 changes: 2 additions & 27 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Expand Down Expand Up @@ -173,29 +173,4 @@
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
END OF TERMS AND CONDITIONS
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# @sinch/node-red-voice-api

A package of nodes for [Node-RED](https://nodered.org) which allows you to connect, initiate and receive voice calls through the Sinch Voice API. For more information about the Sinch Voice API and how to get started, see the [documentation](https://developers.sinch.com/docs/voice/getting-started/).

![Sinch Voice API](docs/images/sinch-voice-api-nodes.png)

## Installation

The first step is to install [Node-RED](https://nodered.org/docs/getting-started/local).

```
$ sudo npm install -g node-red
```

> Compatible with Node-Red version 3.x.x and later
The second step is to install the package. You can either install it directly using the Palette Manager. Instructions can be found here: [Node-RED](https://nodered.org/docs/user-guide/runtime/adding-nodes).

Or install manually using npm:

Navigate to the Node-RED installation and install the package:

```
$ cd ~/.node-red
$ npm install @sinch/node-red-voice-api
```

Run Node-RED locally:
```
$ node-red
```

This will start a server for Node-RED on [http://127.0.0.1:1880/](http://127.0.0.1:1880/).

If the installation of the node package was successful, the Sinch Voice API nodes should be available in the node palette to the left, under the category "Sinch Voice".

## Get started
After you've installed Node-RED and the @sinch/node-red-voice-api package you can start building your flow. To get you started we provide an example [flows.json](docs/examples/flow.json) containing the essentials for initiating and receiving voice calls. To import the flows.json file, open Node-RED in the brower and select the hamburger menu in the top right corner. Choose "Import" and press "select a file to import". The flow file will then be imported on a tab called "Example flow".

The flow.json contains two separate flow examples. For each of the flows there exists a comment node containing additional information about the configuration required to test it out.

### Testing
If you're running Node-RED locally on localhost and want to test receiving voice calls and events, we recommend using a tool like [Ngrok](https://ngrok.com/). This tool allow you to expose your localhost to the internet and makes it possible to route callback events to Node-RED. This is also a useful for testing the native Http-in node provided by Node-RED.

## More about the nodes
This package contains the following four nodes:

### Incoming Call node
Handles and routes inbound voice calls from the Sinch Voice API for a specific application and Sinch number.

In order to receive calls from the Sinch Voice APi, you need to configure a Callback URL on the voice application in the [Sinch dashboard](https://dashboard.sinch.com/voice/apps). The path should be: <i>&lt;node-red-path&gt;/sinch-voice-api/callback</i>.

### Voice Call node
Initiates an outbound voice call using the Sinch Voice API.

In order to initiate calls from the Sinch Voice APi, you need to configure a Callback URL on the voice application in the [Sinch dashboard](https://dashboard.sinch.com/voice/apps). The path should be: <i>&lt;node-red-path&gt;/sinch-voice-api/callback</i>.

### DTMF Answer
Captures the DTMF (Dual Tone Multi Frequency) keypad (0-9, * and #) input from the user response.

### Answered Call Event (ACE)
Stores a SVAML for a call (inbound or outbound) in case of an ACE (Answered Call Event).

## Contributing
See, [CONTRIBUTING.md](CONTRIBUTING.md).

## Copyright and license
Copyright Sinch AB, https://sinch.com under the [Apache 2.0 license](LICENSE).
169 changes: 169 additions & 0 deletions docs/examples/flow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
[
{
"id": "352c14c5878acfd8",
"type": "tab",
"label": "Sinch Voice API",
"disabled": false,
"info": ""
},
{
"id": "de31144f.01d448",
"type": "sinch-voice-incoming-call",
"z": "352c14c5878acfd8",
"application": "",
"endpoint": "",
"svaml": "{\"instructions\":[],\"action\":{\"name\":\"RunMenu\",\"barge\":true,\"menus\":[{\"id\":\"main\",\"mainPrompt\":\"#tts[Welcome to Sinch. You have two options, press 1 or 2]\",\"options\":[{\"dtmf\":\"1\",\"action\":\"return(option1)\"},{\"dtmf\":\"2\",\"action\":\"return(option2)\"}]}]}}",
"x": 550,
"y": 400,
"wires": [
[
"87e5a492.af0318",
"550945e2.9863cc"
]
]
},
{
"id": "87e5a492.af0318",
"type": "sinch-voice-dtmf",
"z": "352c14c5878acfd8",
"action": "option1",
"svaml": "{ \"instructions\": [ { \"name\": \"say\", \"text\": \"Hello, this is a text-to-speech message.\", \"locale\": \"en-US\" } ]}",
"x": 970,
"y": 360,
"wires": [
[
"101f0ef8.fe6f51"
]
]
},
{
"id": "550945e2.9863cc",
"type": "sinch-voice-dtmf",
"z": "352c14c5878acfd8",
"action": "option2",
"svaml": "{\n \"instructions\": [\n {\n \"name\": \"say\",\n \"text\": \"Hello, this is a text-to-speech message.\",\n \"locale\": \"en-US\"\n }\n ]\n}",
"x": 970,
"y": 440,
"wires": [
[
"c72328f1.fba0e8"
]
]
},
{
"id": "101f0ef8.fe6f51",
"type": "debug",
"z": "352c14c5878acfd8",
"name": "debug node",
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1250,
"y": 360,
"wires": []
},
{
"id": "c72328f1.fba0e8",
"type": "debug",
"z": "352c14c5878acfd8",
"name": "debug node",
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1250,
"y": 440,
"wires": []
},
{
"id": "e6feda7a.90f418",
"type": "sinch-voice-call",
"z": "352c14c5878acfd8",
"name": "sinch-voice-call node",
"application": "",
"destinationEndpoint": "",
"cli": "",
"destinationType": "number",
"svaml": "",
"text": "Hello, this is a message from Sinch",
"dtmf": "",
"prompts": "",
"messageType": "text",
"locale": "en-US",
"debug": false,
"x": 825,
"y": 615,
"wires": [
[
"9c065b1e.5fb728"
],
[
"fa63809f.86565"
]
]
},
{
"id": "7efd3e1e.c036c",
"type": "inject",
"z": "352c14c5878acfd8",
"name": "inject node",
"props": [
{
"p": "",
"v": "",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 1,
"topic": "",
"x": 540,
"y": 615,
"wires": [
[
"e6feda7a.90f418"
]
]
},
{
"id": "9c065b1e.5fb728",
"type": "debug",
"z": "352c14c5878acfd8",
"name": "debug node",
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1070,
"y": 580,
"wires": []
},
{
"id": "fa63809f.86565",
"type": "debug",
"z": "352c14c5878acfd8",
"name": "debug node",
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1070,
"y": 640,
"wires": []
}
]
Binary file added docs/images/sinch-voice-api-nodes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e84db72

Please sign in to comment.