Skip to content

Example: Building a Conference Service

alexjg edited this page Jan 17, 2013 · 5 revisions

Building a complete conferencing service is easy with Kazoo! All you need to do is designate a phone number callers will dial into and add some conference bridges, each with their own unique conference room number. There's no limit to the number of conference rooms or participants.

#Getting Started

Before you start, you'll need to get an Authentication Token and know your Account ID. You can find these by logging into Winkstart and clicking on the Developer application, or you can follow the instructions for Generating an Authentication Token to do this pragmatically or via the command-line.

##Step 1: Setup and Authenticate Client

client = kazoo.Client(username="myusername", account_name="My Account Name", password="mypassword")
client.authenticate()

##Step 2: Buy a Phone Number

Now, let's find a good phone number. We'll do a search in the 415 area code, we do this with the search_phone_numbers method on the client, which has as it's first argument the prefix and the quantity of results as the second.

>>>client.search_phone_numbers(1415, quantity=10)
    {u'auth_token': u'ae4a314637bde0055507a4dc1d432a08',
  u'data': [u'+14152334777',
  u'+14152334635',
  u'+14152334629',
  u'+14152334779',
  u'+14152334633',
  u'+14152334741',
  u'+14152334780',
  u'+14152334778',
  u'+14152334630',
  u'+14152334628'],
 u'request_id': u'f61ca4e8ab796f80ad45acc6c00961e8',
 u'revision': u'undefined',
 u'status': u'success'}

Now, pick a number and buy it!

>>>client.create_phone_number(account_id, '+14152334777')

If the purchase is successful, you'll receive a response similar to:

{
    "auth_token":"555555c8d6f213098729999999999999",
    "status":"success",
    "data":{"id":"+14152221188"}
}

##Step 3: Route the Number to Your Conference Service

This step may look a bit complex, but it's very simple. You are creating a callflow that has one module it will send calls to - the conference module. There is no data (settings) for this, and no steps to take after the conference is over (children). If the conference ends, we'll just hangup.

client.create_callflow(account_id,
    { "data" :
        { "numbers" : [ "+14152221188" ],
            "flow" :
            { 
                "module" : "conference",
                "data" : {},
                "children" : {}
           }
       }
   })

After running the above command, you've mapped this phone number to a conference. Congratulations! You should receive the following response:

{ 
    "auth_token":"555555c8d6f213098729999999999999",
    "status":"success",
    "data": {
        "flow": {
            "module" : "conference",
            "data" : {},
            "children" : {}
         },
    "numbers":["+14158911188"],
    "id":"55555514def94f7ce08cf3e1a999999"
},
"revision":"1-7bce3817f7db77b50cce10e86ed63006"

}

##Step 4: Create a Conference Room

Now we create a conference room for use when calling into this conference service.

client.create_conference(account_id, 
    {
        "name" : "Joshs Conference", 
        "conference_numbers" : ["1234"] 
    })

You should receive a response:

{
    "auth_token":"555555c8d6f213098729999999999999",
    "status":"success",
    "data":
        {
            "name":"Joshs Conference",
            "conference_numbers":["1234"],
            "member":{
                "pins":[],
                "numbers":[],
                "play_name":false,
                "join_muted":true,
                "join_deaf":false
            },
            "moderator":
                {
                    "pins":[],
                    "numbers":[],
                    "play_name":false,
                    "join_muted":true,
                    "join_deaf":false
                },
                "require_moderator":false,
                "wait_for_moderator":true,
                "max_members":15,
                "id":"5eb2aac8d6f21309872920aedccbf885"
            },
           "revision":"1-d832f5497369796e1e0f0482584678ee" 
  }

And you're done! You now have a conference bridge which you can reach via (415) 222-1188, pin 1234! Enjoy (smile)

Clone this wiki locally