Interactive Voice Response
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
remnantseed 1a841d5ab9 Merge branch 'feature/context' into develop 1 month ago
_examples early writings 3 months ago
build/docker repair dev service 1 month ago
cmd revs 1 month ago
deployments repair dev service 1 month ago
internal revs 1 month ago
misc go-pjsua2 dep from local 1 month ago
.gitignore update .gitignore, rename deployment dir, update README 2 months ago
README.md go-pjsua2 dep from local 1 month ago
go.mod go-pjsua2 dep from local 1 month ago
go.sum go-pjsua2 dep from local 1 month ago

README.md

TheBigBox’s Interactive Voice Response

How to Run

$ cd deployments
$ cp /path/to/production/config/.env ./.env
$ docker-compose up -d mongo
$ docker-compose up -d webapi caller01

IVR Request Example

{
  "subscriber_id": "developertampan",
  "intro_text": "Selamat datang di layanan The Big Box.",
  "closing_text": "Terima kasih, pilihan Anda akan diproses.",
  "dtmf_timeout_text": "Maaf, Anda tidak memasukan pilihan. Panggilan ini akan diakhiri.",
  "unknown_action_text": "Maaf, pilihan yang Anda masukan tidak dikenali. Panggilan ini akan diakhiri.",
  "options": [
    {
      "key": "1",
      "text": "Untuk layanan ei pi ai, tekan satu.",
      "action": "next",
      "suboptions": [
        {
          "key": "1",
          "text": "Untuk informasi layanan, tekan satu.",
          "action": "next",
          "suboptions": [
            {
              "key": "1",
              "text": "Untuk informasi layanan SMS OTP, tekan satu.",
              "action": "finish"
            },
            {
              "key": "2",
              "text": "Untuk informasi layanan SMS Notification, tekan dua.",
              "action": "finish"
            },
            {
              "key": "3",
              "text": "Untuk informasi layanan Voice OTP, tekan tiga.",
              "action": "finish"
            },
            {
              "key": "0",
              "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
              "action": "back"
            }
          ]
        },

        {
          "key": "2",
          "text": "Untuk laporan gangguan, tekan dua.",
          "action": "next",
          "suboptions": [
            {
              "key": "1",
              "text": "Untuk laporan gangguan layanan SMS OTP, tekan satu.",
              "action": "finish"
            },
            {
              "key": "2",
              "text": "Untuk laporan gangguan layanan SMS Notification, tekan dua.",
              "action": "finish"
            },
            {
              "key": "3",
              "text": "Untuk laporan gangguan layanan Voice OTP, tekan tiga.",
              "action": "finish"
            },
            {
              "key": "0",
              "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
              "action": "back"
            }
          ]
        },
        {
          "key": "3",
          "text": "Untuk informasi tagihan Anda, tekan tiga.",
          "action": "next",
          "suboptions": [
            {
              "key": "1",
              "text": "Untuk informasi tagihan pascabayar, tekan satu.",
              "action": "next",
              "suboptions": [
                {
                  "key": "4",
                  "text": "Untuk informasi tagihan pascabayar SMS OTP, tekan empat.",
                  "action": "finish"
                },
                {
                  "key": "5",
                  "text": "Untuk informasi tagihan pascabayar SMS Notification, tekan lima.",
                  "action": "finish"
                },
                {
                  "key": "6",
                  "text": "Untuk informasi tagihan pascabayar Voice OTP, tekan enam.",
                  "action": "finish"
                },
                {
                  "key": "0",
                  "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
                  "action": "back"
                }
              ]
            },
            {
              "key": "2",
              "text": "Untuk informasi tagihan prabayar, tekan dua.",
              "action": "next",
              "suboptions": [
                {
                  "key": "7",
                  "text": "Untuk informasi tagihan prabayar SMS OTP, tekan tujuh.",
                  "action": "finish"
                },
                {
                  "key": "8",
                  "text": "Untuk informasi tagihan prabayar SMS Notification, tekan delapan.",
                  "action": "finish"
                },
                {
                  "key": "9",
                  "text": "Untuk informasi tagihan prabayar Voice OTP, tekan sembilan.",
                  "action": "finish"
                },
                {
                  "key": "0",
                  "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
                  "action": "back"
                }
              ]
            },
            {
              "key": "0",
              "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
              "action": "back"
            }
          ]
        },
        {
          "key": "0",
          "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
          "action": "back"
        }
      ]
    },

    {
      "key": "2",
      "text": "Untuk layanan big data, tekan dua.",
      "action": "next",
      "suboptions": [
        {
          "key": "1",
          "text": "Untuk laporan gangguan, tekan satu.",
          "action": "finish"
        },
        {
          "key": "2",
          "text": "Untuk informasi tagihan Anda, tekan dua.",
          "action": "finish"
        },
        {
          "key": "3",
          "text": "Untuk menghubungi customer service, tekan tiga.",
          "action": "call_to",
          "call_to": "020987654321"
        },
        {
          "key": "0",
          "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
          "action": "back"
        }
      ]
    }
  ],
  "callback": "http://mockbin.org/request",
  "phone_num": "08999xxxxxx"
}

Available actions:

  1. "next" go to the next option branch.
  2. "back" go to the previous option branch.
  3. "call_to" to call to the targeted phone number that is set in the "call_to" field.
  4. "finish" to end the IVR.

Request example using curl:

curl -i -X POST http://0.0.0.0:8080/ivr -d '{
  "subscriber_id": "developertampan",
  "intro_text": "Selamat datang di layanan The Big Box.",
  "closing_text": "Terima kasih, pilihan Anda akan diproses.",
  "dtmf_timeout_text": "Maaf, Anda tidak memasukan pilihan. Panggilan ini akan diakhiri.",
  "unknown_action_text": "Maaf, pilihan yang Anda masukan tidak dikenali. Panggilan ini akan diakhiri.",
  "options": [
    {
      "key": "1",
      "text": "Untuk layanan ei pi ai, tekan satu.",
      "action": "next",
      "suboptions": [
        {
          "key": "1",
          "text": "Untuk informasi layanan, tekan satu.",
          "action": "next",
          "suboptions": [
            {
              "key": "1",
              "text": "Untuk informasi layanan SMS OTP, tekan satu.",
              "action": "finish"
            },
            {
              "key": "2",
              "text": "Untuk informasi layanan SMS Notification, tekan dua.",
              "action": "finish"
            },
            {
              "key": "3",
              "text": "Untuk informasi layanan Voice OTP, tekan tiga.",
              "action": "finish"
            },
            {
              "key": "0",
              "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
              "action": "back"
            }
          ]
        },

        {
          "key": "2",
          "text": "Untuk laporan gangguan, tekan dua.",
          "action": "next",
          "suboptions": [
            {
              "key": "1",
              "text": "Untuk laporan gangguan layanan SMS OTP, tekan satu.",
              "action": "finish"
            },
            {
              "key": "2",
              "text": "Untuk laporan gangguan layanan SMS Notification, tekan dua.",
              "action": "finish"
            },
            {
              "key": "3",
              "text": "Untuk laporan gangguan layanan Voice OTP, tekan tiga.",
              "action": "finish"
            },
            {
              "key": "0",
              "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
              "action": "back"
            }
          ]
        },
        {
          "key": "3",
          "text": "Untuk informasi tagihan Anda, tekan tiga.",
          "action": "next",
          "suboptions": [
            {
              "key": "1",
              "text": "Untuk informasi tagihan pascabayar, tekan satu.",
              "action": "next",
              "suboptions": [
                {
                  "key": "4",
                  "text": "Untuk informasi tagihan pascabayar SMS OTP, tekan empat.",
                  "action": "finish"
                },
                {
                  "key": "5",
                  "text": "Untuk informasi tagihan pascabayar SMS Notification, tekan lima.",
                  "action": "finish"
                },
                {
                  "key": "6",
                  "text": "Untuk informasi tagihan pascabayar Voice OTP, tekan enam.",
                  "action": "finish"
                },
                {
                  "key": "0",
                  "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
                  "action": "back"
                }
              ]
            },
            {
              "key": "2",
              "text": "Untuk informasi tagihan prabayar, tekan dua.",
              "action": "next",
              "suboptions": [
                {
                  "key": "7",
                  "text": "Untuk informasi tagihan prabayar SMS OTP, tekan tujuh.",
                  "action": "finish"
                },
                {
                  "key": "8",
                  "text": "Untuk informasi tagihan prabayar SMS Notification, tekan delapan.",
                  "action": "finish"
                },
                {
                  "key": "9",
                  "text": "Untuk informasi tagihan prabayar Voice OTP, tekan sembilan.",
                  "action": "finish"
                },
                {
                  "key": "0",
                  "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
                  "action": "back"
                }
              ]
            },
            {
              "key": "0",
              "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
              "action": "back"
            }
          ]
        },
        {
          "key": "0",
          "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
          "action": "back"
        }
      ]
    },

    {
      "key": "2",
      "text": "Untuk layanan big data, tekan dua.",
      "action": "next",
      "suboptions": [
        {
          "key": "1",
          "text": "Untuk laporan gangguan, tekan satu.",
          "action": "finish"
        },
        {
          "key": "2",
          "text": "Untuk informasi tagihan Anda, tekan dua.",
          "action": "finish"
        },
        {
          "key": "3",
          "text": "Untuk menghubungi customer service, tekan tiga.",
          "action": "call_to",
          "call_to": "020987654321"
        },
        {
          "key": "0",
          "text": "Untuk kembali ke opsi sebelumnya, tekan nol.",
          "action": "back"
        }
      ]
    }
  ],
  "callback": "http://mockbin.org/request",
  "phone_num": "08999xxxxxx"
}'

Callback Request

Success result callback request:

GET http://mockbin.org/request?status_code=0&result=1,2,3

Fail result callback request:

GET http://mockbin.org/request?status_code=0&error=Unknown+action

Development

  1. Download pjsip from https://www.pjsip.org/download.htm then put it into /path/to/pjsip
  2. Clone this source code from git repo to /path/to/ivr
  3. Copy all files from /path/to/ivr/misc/_pjsua2_linux to /path/to/ivr/../go-pjsua2/ or /path/to/go-pjsua2 for short (ivr dir must be in the same dir with go-pjsua2 dir)
  4. cd to /path/to/go-pjsua2 then generate it using Swig:
    swig -c++ -go -cgo -intgosize 64 \
      -outcurrentdir \
      -I/usr/local/include \
      /path/to/pjsip/pjsip-apps/src/swig/pjsua2.i
    
  5. Open /path/to/ivr using VSCode
  6. Enjoy