Giter VIP home page Giter VIP logo

click2call-1's Introduction

This is a web callback PHP backend along with the relevant Asterisk extensions.

It plays French and English annoucements.

the PHP script expects two variables from the HTTP POST:

  • The phone number to callback the visitor on
  • The language for the announcement

When the script is called, a new object with the phoneNumber class is created. The checkNumber() method cleans the phone number to only digits, checks that the number is valid, appends '1' at the beginning of the number and puts it in the digits property. It also sets the isValid property to true.

It checks if the language property is valid ('FR' or 'EN').

If the number is valid and the language is valid, then it opens a TCP socket to Asterisk Manager Interface using a TLS connection and sends an originate message for the visitor to be called back, connected to the callback extension in the appropriate language and then bridges the call to my cell phone.

It handles socket errors (i.e. the Asterisk host is unreachable), AMI messages errors (i.e. the AMI credentials are invalid, the call cannot be originated etc) and returns a JSON object with the result of the API call.

The returned JSON object is: { "socket":true|false, "amiLogin":true|false, "amiOrig":true|false, "amiLogoff":true|false, "callSpooled":true|false }

If callSpooled is true, then all went well and parties will be rung as expected. If callSpooled is false, then it is possible to check what went wrong by checking the booleans for every stage of the callback operation.

"socket":false means the API couldn't reach the Asterisk host, either because the host is unreachable, there is a mistake in the hostname or the port number is wrong. "amiLogin":false most likely means that the submitted AMI credentials are not valid "amiOrig":false means that the Originate failed "amiLogoff":false means that the API didn't log off AMI "callSpooled":false when any preceding operation failed. As a result, there won't be any callback. If one doesn't wish to display detailed error messages then this would be the only property to check to assert the success or failure of the callback request.

click2call-1's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.