Skip to content

Commit 8dcbbcf

Browse files
author
Abdulhakim Ajetunmobi
authored
Node Voice Outbound - add enable voice cap (#25)
1 parent 657fbc8 commit 8dcbbcf

File tree

7 files changed

+49
-16
lines changed

7 files changed

+49
-16
lines changed

tutorials/voice_api-node-outbound/.astro/data-store.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tutorials/voice_api-node-outbound/src/content/docs/03-initialize-client.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Copy this code into `make-call.js`
1515

1616
```js
1717
const { Vonage } = require('@vonage/server-sdk');
18-
const { SMS } = require('@vonage/messages');
1918

2019
const TO_NUMBER = ''
2120
const VONAGE_NUMBER = process.env.VONAGE_NUMBER;

tutorials/voice_api-node-outbound/src/content/docs/04-make-call-code.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ This code will make the call. Copy into the bottom of `make-call.js`:
66

77
```js
88
vonage.voice.createOutboundCall({
9-
to: [
10-
{
11-
type: 'phone',
12-
number: TO_NUMBER,
13-
},
14-
],
15-
from: {
16-
type: 'phone',
17-
number: VONAGE_NUMBER,
18-
}})
19-
.then((resp) => console.log(resp))
20-
.catch((error) => console.error(error));
9+
to: [{ type: 'phone', number: TO_NUMBER }],
10+
from: { type: 'phone', number: VONAGE_NUMBER },
11+
ncco: [
12+
{
13+
action: 'talk',
14+
text: 'Hello, this is an outbound call from the Vonage Voice API'
15+
}
16+
]
17+
})
18+
.then((resp) => console.log(resp))
19+
.catch((error) => console.error(error));
2120
```
2221

2322
This uses the Vonage Node.js SDK to make an outbound call. If successful the response, containing the call UUID will be printed out to the console. Otherwise the error message will be printed out.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: Enable Voice
3+
---
4+
5+
To make a call, you need to enable the voice capability on your Vonage application. Copy this code into the `enable-voice.js` file:
6+
7+
```js
8+
const { Vonage } = require('@vonage/server-sdk');
9+
10+
const vonage = new Vonage({
11+
apiKey: process.env.VONAGE_API_KEY,
12+
apiSecret: process.env.VONAGE_API_SECRET,
13+
applicationId: process.env.VONAGE_APPLICATION_ID,
14+
privateKey: process.env.VONAGE_PRIVATE_KEY,
15+
});
16+
17+
vonage.applications.getApplication(process.env.VONAGE_APPLICATION_ID)
18+
.then((app) => {
19+
app.capabilities = {
20+
voice: {}
21+
}
22+
vonage.applications.updateApplication(app)
23+
.then(() => console.log("App Updated"))
24+
.catch((error) => console.dir(error));
25+
})
26+
.catch((error) => console.error(error));
27+
```
28+
29+
Then run this command in the Terminal:
30+
31+
```sh
32+
node enable-voice.js
33+
```
34+
File renamed without changes.
File renamed without changes.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"files": [
3-
"make-call.js"
3+
"make-call.js",
4+
"enable-voice.js"
45
],
56
"panels": [
67
"terminal"
78
],
8-
"version": "0.1.0"
9+
"version": "0.2.0"
910
}

0 commit comments

Comments
 (0)