title: Twilio JS Library
body: <p>I am currently using the <a href="http://twilio-python.readthedocs.org/en/latest/" rel="nofollow">Python helper</a> and <a href="https://www.twilio.com/docs/client/twilio-js" rel="nofollow">Js library</a> for <a href="http://twilio.com" rel="nofollow">Twilio</a>. I am having a hard time determining how I can I be able to determine if my user is online or not. I know a function for js library containing about <strong>Twilio.Device.presence</strong>. It was successfully showing all the online user. But how can I determine if the user I am calling currently is online? </p>
  
  <p>In the field number is where I am going to call:</p>
  
  <pre><code>&lt;input type="text" id="number" name="number"
    placeholder="Enter a phone number or client to call"/&gt;
  </code></pre>
  
  <p>In this function:</p>
  
  <pre><code>Twilio.Device.presence(function (pres) {
      if (pres.available) {
          // create an item for the client that became available
          $("&lt;li&gt;", {id: pres.from, text: pres.from}).click(function () {
              $("#number").val(pres.from);
              call();
          }).prependTo("#people");
      } else {
          // find the item by client name and remove it
          $("#" + pres.from).remove();
      }
  });
  </code></pre>
  
  <p>The <code>pres.from</code> is the user that are online. How can I be able to for loop on it and check if the data in the <code>number</code> field is same.
  Or how can I pass from the function to my views?. </p>
  
  <p>Thanks for the help.</p>