Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Global rule:
* @Bandwidth-Samples/dx
* @Bandwidth-Samples/band-swi @Bandwidth-Samples/band-devx
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2

updates:
- package-ecosystem: composer
directory: /
schedule:
interval: monthly
open-pull-requests-limit: 5
ignore:
- dependency-name: "bandwidth/sdk"
update-types:
- version-update:semver-minor
- version-update:semver-patch
groups:
dependencies:
patterns:
- "*"
exclude-patterns:
- "bandwidth/sdk"
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Test

on:
pull_request:
branches:
- main
schedule:
- cron: "0 9 * * 1"

jobs:
contract-test:
name: Contract Test
uses: Bandwidth-Samples/sample-app-tooling/.github/workflows/php.yml@main
with:
sample: voice-bridge
36 changes: 6 additions & 30 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Compiled class file
*.class
/target
/out
/dist
/bin
/obj
# macOS System file
.DS_Store

# Environment file
.env

# IntelliJ
.idea/
Expand All @@ -13,30 +11,8 @@
# Vs Code
.vscode/

# Node
/node_modules

# PHP
**/vendor/*
*.phar
/vendor/

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Bandwidth Samples
Copyright (c) 2026 Bandwidth Samples

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
51 changes: 38 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
# Voice-Bridge-PHP
<a href="http://dev.bandwidth.com"><img src="https://s3.amazonaws.com/bwdemos/BW-VMP.png"/></a>
</div>
# Voice Bridge

<a href="https://dev.bandwidth.com/docs/voice/programmable-voice/quickStart/">
<img src="./icon-voice.svg" title="Voice Quick Start Guide" alt="Voice Quick Start Guide"/>
</a>

# Table of Contents

<!-- TOC -->

- [Voice-Bridge-PHP](#Voice-Bridge-PHP)
- [Description](#description)
- [Bandwidth](#bandwidth)
- [Environmental Variables](#environmental-variables)
- [Running the Application](#running-the-application)
- [Callback URLs](#callback-urls)
- [Ngrok](#ngrok)

<!-- /TOC -->

# Description
A simple PHP sample application demonstrating how to bridge two live calls using the Bandwidth V2 Voice API.
This sample app masks a phone call through a Bandwidth phone number using Bandwidth's Bridge BXML verb. Once configured, anyone who calls your Bandwidth phone number will be bridged to the masked number without either party members knowing the other's phone number.

In the Bandwidth Dashboard, set the Application's `Call initiated callback URL` to `<BASE_CALLBACK_URL>/callbacks/inbound/voice`. This can also be done via the Dashboard API by setting `CallInitiatedCallbackUrl`. Once configured, any calls made to a number associated with that application will cause this app to create a new call to the `USER_NUMBER`. This call will come from your `BW_NUMBER` and the original call will be bridged to this one once accepted.

Once the callee at `USER_NUMBER` confirms the call, the call flow will appear as such:

`Random Number <-> BW_NUMBER <-> USER_NUMBER` - if the `BW_NUMBER` environment variable is the number called.

`Random Number <-> Other BW_NUMBER <-> BW_NUMBER <-> USER_NUMBER` - if the `BW_NUMBER` environment variable is different from the number called.

# Bandwidth

Expand All @@ -30,21 +40,36 @@ For more information about API credentials see [here](https://dev.bandwidth.com/
The sample app uses the below environmental variables.
```sh
BW_ACCOUNT_ID # Your Bandwidth Account Id
BW_USERNAME # Your Bandwidth API Username
BW_PASSWORD # Your Bandwidth API Password
BW_VOICE_APPLICATION_ID # Your Voice Application Id created in the dashboard
BW_MESSAGING_APPLICATION_ID # Your Messaging Application Id created in the dashboard
BASE_CALLBACK_URL # Your public base url
BW_CLIENT_ID # Your Bandwidth API OAuth Client Id
BW_CLIENT_SECRET # Your Bandwidth API OAuth Client Secret
BW_NUMBER # The Bandwidth phone number involved with this application
USER_NUMBER # The number dialed out to when an inbound call is received on your Bandwidth number
BW_VOICE_APPLICATION_ID # Your Voice Application Id created in the dashboard
BASE_CALLBACK_URL # Your public base url to receive Bandwidth Webhooks. No trailing '/'
LOCAL_PORT # The port number you wish to run the sample on
```

# Running the Application

To install the required packages for this app, run the command:

```sh
composer install
```

Use the following command to run the application:

```sh
composer start
```

# Callback URLs

For a detailed introduction to Bandwidth Callbacks see https://dev.bandwidth.com/guides/callbacks/callbacks.html

Below are the callback paths:
* `/callbacks/inboundCall`
* `/callbacks/outboundCall`
* `/callbacks/outbound/voice`
* `/callbacks/inbound/voice`

## Ngrok

Expand All @@ -53,4 +78,4 @@ After you have downloaded and installed `ngrok` run the following command to ope
```cmd
ngrok http $LOCAL_PORT
```
You can view your public URL at `http://127.0.0.1:{LOCAL_PORT}` after ngrok is running. You can also view the status of the tunnel and requests/responses here.
You can view your public URL at `http://127.0.0.1:4040` after ngrok is running. You can also view the status of the tunnel and requests/responses here.
18 changes: 14 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
{
"name": "bandwidth-samples/voice-bridge-php",
"description": "Bandwidth Sample App Demonstrating the Bridge BXML Verb",
"type": "project",
"license": "MIT",
"require": {
"bandwidth/sdk": "^8.1.2",
"slim/slim": "^4.7",
"slim/http": "^1.2",
"slim/psr7": "^1.3"
"php": "^8.1",
"bandwidth/sdk": "14.0.1",
"slim/slim": "4.15.3",
"slim/psr7": "1.8.0"
},
"scripts": {
"start": [
"Composer\\Config::disableProcessTimeout",
"@php start.php"
]
}
}
Loading
Loading