-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from nexmo-community/update-project
Updates project
- Loading branch information
Showing
3 changed files
with
39 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,37 @@ | ||
This is the sample code for the "Streaming Audio into a Call with Node.js" blog post. | ||
# Streaming Audio into a Call with Node.js | ||
|
||
## Running the application | ||
This is the sample code for the [Streaming Audio into a Call with Node.js](https://developer.vonage.com/en/blog/stream-audio-into-a-phone-call-with-node-js) blog post. | ||
This project showcases how to stream audio into a call using Node.js. It uses the Vonage Server SDK to make a call to a specified number, then streams audio into the call. | ||
|
||
1. Create a new voice app and link an existing number to it, or purchase a new one. Make a note of the application id. | ||
2. Download the private key to your application directory. | ||
3. Run `ngrok http 3000` to start tunneling. | ||
4. Change the hostname of the `silence.mp3` URL in `/public/answer.json` to match your `ngrok` hostname. | ||
5. Copy `example.env` to `.env` and configure your API key, secret, private key file path, to/from numbers and `ngrok` URL. | ||
6. Run `npm install` to install dependencies. | ||
7. Run `node server.js` in the root directory to start the app. | ||
8. Make a `GET` request to `http://localhost:3000/call` to call the configured `TO_NUMBER`. | ||
## Prerequisites | ||
|
||
If all goes well, you should hear a message followed by silence. A few seconds later you will hear some music for 30 seconds which then stops. | ||
- Node.js and npm installed. | ||
- A Vonage account with a Voice API application and linked number. | ||
- Ngrok installed and set up. | ||
- A public domain music file. | ||
|
||
**Note**: The music file this application uses (*City Sunshine* by Kevin MacLeod) is in the public domain. See https://freepd.com. | ||
## Setup and Installation | ||
|
||
Follow the steps below to set up and run this application: | ||
|
||
1. **Create a Voice API application:** Use your Vonage account to create a new voice app. Link an existing number to it, or purchase a new one. Note down the application id. | ||
|
||
2. **Download the private key:** Download the private key associated with your voice app to your application directory. | ||
|
||
3. **Start an ngrok tunnel:** Run `ngrok http 3000` in your terminal to start an ngrok tunnel. | ||
|
||
4. **Update the silence.mp3 URL:** In the `/public/answer.json` file, change the hostname of the `silence.mp3` URL to match your ngrok hostname. | ||
|
||
5. **Configure environment variables:** Rename the `example.env` file to `.env` and update the variables with your API key, secret, private key file path, and your ngrok URL. Also, specify the 'to' and 'from' numbers for making the call. | ||
|
||
6. **Install dependencies:** Run `npm install` in your terminal from the root directory of the project. | ||
|
||
7. **Start the application:** Run `node server.js` to start the app. | ||
|
||
## Usage | ||
|
||
To initiate a call, make a `GET` request to `http://localhost:3000/call`. This will call the configured `TO_NUMBER`. | ||
|
||
If all goes well, you will first hear a message, followed by silence. After a few seconds, music will play for 30 seconds and then stop. | ||
|
||
**Note**: The music file this application uses (*City Sunshine* by Kevin MacLeod) is in the public domain. For more information, visit [FreePD](https://freepd.com). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters