Git Product home page Git Product logo

att.js's Introduction

att.js

Client library for turning your browser into a phone.

For more info/demos visit: https://js.att.io

How to Make a Phone Call

var att = $.att({
  // we just pass our accessToken
  apiKey: "YOUR ACCESS TOKEN",
  // specify what we want to do when
  // we're ready to make calls
  onReady: function () {
    window.activeCall = att.phone.dial('1-800-444-4444');
  },
  phone: {
    onIncomingCall: function (call) {
      window.activeCall = call;
      // auto answer
      call.answer();
    }
  }
});

Configuring att.js

The configuration settings for att.js are:

  • apiKey: Your OAuth access token.
  • log: Defaults to true to include verbose console log output.

Additionally, there are several callback hooks for managing a call's lifecycle:

  • onReady
  • onUnReady
  • onError
  • onCalling
  • onCallBegin
  • onCallEnd
  • onIncomingCalli
  • onOutgoingCall

Each of which is called with a call object.

When specifying the callbacks, you may either include them directly as so:

var att = $.att({
  apiKey: "YOUR ACCESS TOKEN",
  onReady: function () {
    window.activeCall = att.phone.dial('1-800-444-4444');
  },
  onIncomingCall: function (call) {...}
  onCallEnd: function (call) {...}
});

or you may follow the convention for the Phono API by putting the callbacks in a phone dictionary:

var att = $.att({
  apiKey: "YOUR ACCESS TOKEN",
  onReady: function () {
    window.activeCall = att.phone.dial('1-800-444-4444');
  },
  phone: {
    onIncomingCall: function (call) {...}
    onCallEnd: function (call) {...}
  }
});

Creating and Interacting with a Call

To start a call, you can use att.dial(), or the equivalent att.phone.dial():

var att = $.att({...});
var call = att.dial('18005555555', {
    onAnswer: function () {...}
});

You may also pass additional callbacks specific for the call. These are:

  • onRing
  • onAnswer
  • onHangup
  • onError

Once a call object has been created, you can control and interact with the call session using:

  • call.answer(): Accept an incoming call.
  • call.hangup(): End the call.

Once you answer a call, you can find the number of the caller in the call.initiator field.

Working with Phone Numbers

If you want to clean and sanitize a user provided phone number to the standard US format, you can use:

var number = $.att.phoneNumber.stringify('800555555');

You can also parse numbers like so:

var number = $.att.phoneNumber.stringify('1 (800) CALL-ATT');

Contributing to this library

Prerequisits

  • Node.js 0.8.16
  • npm

Steps

  1. install dependencies:
npm install .
  1. Make edits in /src

  2. build att.js and minified version

node build.js

Credits

The AT&T Foundry Phono

Developers

att.js's People

Contributors

henrikjoreteg avatar legastero avatar ztsyed avatar

Watchers

AJ Smith avatar James Cloos 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.