APIdaze Javascript API
This library provides audio conferences, automated voice responses, selecting dialtone option and more.
User will not be able to select phone number. Instead he will call an "External Script" which is a XML definition of what will happen during the call. External Scripts are stored on APIdaze server.
For use cases where user can type phone number consider REST API.
Either execute in your project directory
npm install apidaze-js
and add to your code
const APIdaze = require('apidaze-js')
or add a html tag
<script src="https://api4.apidaze.io/javascript/releases/APIdaze-3.0.0-dev-master.js" />
Make sure you can access this page that is used to define External Scripts.
If you don't have account, you can create one here.
To initialize a client, follow these instructions.
And to read more about possibilites of External Scripts, go here.
Name | Default value | Type | Possible values | Description |
---|---|---|---|---|
apiKey | undefined |
string | A valid API key | The API key of the application on the dashboard to use |
region | undefined |
string | us-east , us-west , eu-central , eu-west , ap-southeast |
Defines the region for the client to connect. |
iceServers | [{ urls: "stun:stun.l.google.com:19302" }] |
RTCIceServer[] | An array of RTCIceServers | Defines how to connect to ICE servers |
wsurl | undefined |
string | A valid secure WebSocket server URL for server communication | Defines which server to connect. This argument has precedence over the region argument. |
Name | Default value | Type | Possible values | Description |
---|---|---|---|---|
audioInputDeviceId | undefined |
string | Any audio input device ID | The ID of the audio input device to use for the specified call. |
audioOutputDeviceId | undefined |
string | Any audio output device ID | The ID of the audio output device to use for the specified call. |
iceServers | [{ urls: "stun:stun.l.google.com:19302" }] |
RTCIceServer[] | An array of RTCIceServers | Defines how to connect to ICE servers for the specified call. |
tagId | apidaze-audio-video-container-id-{randomString} |
string | A valid secure WebSocket server URL for server communication | The ID of the element where the HTMLMediaElement will be appended to. |
Apart from what's shared below, one may check the example in samples/audio_conference/index.html that demonstrates the followings;
- Instantiating a client
- Joining a conference call with initial audio media tracks for input as well as output
- Updating the audio media track for input and output after the call is initiated
- Enumerating the media devices
Once a call object is instantiated, one may use the method that resides at Call#setAudioInputDevice with an argument of valid audio input device ID as the following;
const call = Client.call();
call.setAudioInputDevice(deviceId);
Then the audio input media track will be respectively updated.
As in updating the audio input, one may use the method at Call#setAudioOutputDevice with an argument of valid audio output device ID as the following;
const call = Client.call();
call.setAudioOutputDevice(deviceId);
- Visit https://backoffice.voipinnovations.com/ProgrammableTelco/ExternalScripts.aspx
- Click create new script button
- Enter name of your choice and this content of External Script
<document>
<work>
<answer />
<wait>1</wait>
<speak>Welcome, you are joining the conference.</speak>
<conference>test</conference>
<hangup />
</work>
</document>
4. Click create script, wait for cofirmation, close the editor
5. Find script by the name and copy the visible apiKey (c7fee939 on screenshot)
6. Clone repository git clone https://github.com/apidaze/apidaze-js.git
7. Install npm dependencies cd apidaze-js
and npm install
8. Start a webserver npm run start
9. Open https://localhost:9000
10. Warning about missing certificate will be displayed, click "advanced" and "proceed to localhost (unsafe)"
11. Select "API key check" from list of examples
12. Type apiKey from step 4. and click "check" button
If all went good, result should look like this
- Fork this repository
- Make a copy of file
cypress/config.template.js
namedcypress/config.js
and inside its content write apiKey from step 4. of How to run examples - Work on your change
- When ready, please verify that code is matching linter and tests are passing by running
npm run start
and in separate console:npm run test:all
- If integration tests are failing use
npm run cypress
to find a reason - When all tests are passing create a pull request