35
loading...
This website collects cookies to deliver better user experience
fonos auth:login
Access your Fonos infrastructure
Press ^C at any time to quit.
? api endpoint api.fonoster.io
? access key id psanders
? access key token *************************...
? ready? Yes
Accessing endpoint api.fonoster.io... Done
Play
- It takes an URL or file and streams the sound back to the calling partySay
- It takes a text, synthesizes the text into audio, and streams the resultGather
- It waits for DTMF events and returns back the resultRecord
- It records the voice of the calling party and saves the audio on the Storage sub-systemMute
- It tells the channel to stop sending media, thus effectively muting the channelUnmute
- It tells the channel to allow media flowmkdir voiceapp
cd voiceapp
npm init # and follow the wizard
...
package name: (voiceapp)
version: (1.0.0)
description: My voice app
entry point: (index.js)
test command:
git repository:
keywords:
author: Pedro Sanders
license: MIT
About to write to /Users/yourusername/Projects/voiceapp/package.json:
{
"name": "voiceapp",
"version": "1.0.0",
"description": "My voice app",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Pedro Sanders",
"license": "MIT"
}
Is this OK? (yes) yes
index.js
with the following content:const { VoiceServer } = require("@fonos/voice");
const voiceServer = new VoiceServer();
voiceServer.listen((req, res) => {
console.log(req);
res.play("sound:hello-world");
});
npm i --save @fonos/voice
node index.js
info: initializing voice server
info: starting voice server on @ 0.0.0.0, port=3000
Your app will live at http://127.0.0.1:3000
. ⚠️ Be sure to leave the server up!
ngrok http 3000
Forwarding URL
for use in the next step.username
, password
, and host
you obtained from your SIP Service Provider for this section.fonos providers:create
This utility will help you create a new Provider
Press ^C at any time to quit.
? friendly name VOIPMS
? username 215706
? secret [hidden]
? host newyork1.voip.ms
? transport tcp
? expire 300
? ready? Yes
Creating provider YourServiceProvider... Done
If your Provider doesn't accept E164, you can append the --ignore-e164-validation
fonos numbers:create --ignore-e164-validation
This utility will help you create a new Number
Press ^C at any time to quit.
? number in E.164 format (e.g. +16471234567) 9842753574
? service provider VOIPMS
? aor link (leave empty)
? webhook https://5a2d2ea5d84d.ngrok.io # Replace with the value you obtained from Ngrok
? ready? Yes
Creating number +17853178071... KyjgGEkasj
⚠️ Be sure to replace the information with what was given to you by your Provider.
Egreess Number
. Also, make sure to use an "unclaimed" uri
or you will receive this error: "› Error: This Domain already exists." fonos domains:create
This utility will help you create a new Domain
Press ^C at any time to quit.
? friendly name Acme Corp
? domain uri (e.g acme.com) sip.acme.com
? egress number none
? egress rule .*
? ready? Yes
Creating domain Acme Corp... Jny9B_qaIh
⚠️ In the demo server, you don't need to own the Domain. Any URI is fair game!
voiceapp
, with:npm i --save @fonos/sdk
call.js
with the following code:// This will load the SDK and reuse your Fonos credentials
const Fonos = require("@fonos/sdk");
const callManager = new Fonos.CallManager();
// Few notes:
// 1. Update the from to look exactly as the Number you added
// 2. Use an active phone or mobile
// 3. Replace the webhook with the one from your Ngrok
callManager.call({
from: "9842753574",
to: "17853178070",
webhook: "https://5a2d2ea5d84d.ngrok.io",
ignoreE164Validation: true
})
.then(console.log)
.catch(console.error);
node call.js
username
, password
, and host
. If your Provider has an Admin console, check if you can see the registration from Fonos.from
matches the Number given to you by your Provider. Also, double-check the to
has the correct prefix (for example, +1, etc.).fonos bug
command to start a GitHub issue. Or, you can use the fonos feedback
command to complete a short survey (which takes less than 30 seconds).