Developer reference

Everything your own code can do with Callbird: show live availability, open your Callbird page, hear what happens during an instant video call, and pass in who a logged-in visitor is. All of it is live today. For your own buttons and server webhooks, see SDK and webhooks (early access).

Live availability

Our button script, or a plain JSON request, tells you whether someone is free right now.

Call events

Your page hears when a call is requested, acknowledged, started and ended, and why it ended.

Verified visitors

Sign a logged-in visitor's details on your server so your team knows who's calling.

What you can build

  • ✓ Your own call buttons that change when someone is free
  • ✓ Call logging in your analytics or CRM, from the call events
  • ✓ A thank-you page or reset screen after a call ends
  • ✓ Calls that arrive with your customer's name and account details

How calls work

Calls always run inside Callbird's own page: in a page embed (iframe), the corner widget, a popup, a new tab or an overlay. Your code can't place a call by itself. The visitor presses the instant video call button on the Callbird page, which is also when the browser asks for their microphone. Instant video calls need the Instant plan ($29/mo) and the calls switch turned on. New accounts start with it off.

Installation

For live buttons, add our button script once on the page. Nothing else is needed for the status endpoints or the call events.

<script src="https://www.callbird.com/process/widget/button.js" async defer></script>

What it does

  • • Finds every element with data-callbird-org or data-callbird-user when the page has loaded
  • • Checks availability every 30 seconds for each one and updates its text and dot
  • • No dependencies. Plain JavaScript.
  • • Adds window.Callbird with init(), open() and destroyDetached()

Setting up buttons

Any element can be a live button. Put the settings in data-callbird-* attributes. The button maker in your dashboard writes these for you.

<a href="https://www.callbird.com/yourteam/"
   data-callbird-org="YOUR_ORG_ID"
   data-callbird-mode="modal"
   data-callbird-online-text="Talk to us now"
   data-callbird-offline-text="Book a meeting">
  <span data-callbird-label>Book a meeting</span>
</a>

Attributes

Attribute Default Description
data-callbird-org Your team ID. "Online" when anyone on the team is free.
data-callbird-user A username. "Online" when that person is free. Ignored if data-callbird-org is also set.
data-callbird-mode popup popup, newtab or modal
data-callbird-online-text Put into [data-callbird-label] when online
data-callbird-offline-text Put into [data-callbird-label] when offline
data-callbird-online-sub Put into [data-callbird-sublabel] when online
data-callbird-offline-sub Put into [data-callbird-sublabel] when offline
data-callbird-dot true false leaves out the green status dot
data-callbird-href The page to open when the element has no href

Single-page apps

The script scans the page once when it loads. After you add buttons, call Callbird.init(). It skips buttons it has already set up, so it's safe to call on every route change. Buttons removed from the page stop checking on their own; call Callbird.destroyDetached() to stop them straight away.

// After your router renders a new view
if (window.Callbird) window.Callbird.init();

Status endpoints

The button script reads these. You can too, from any website. They're plain GET requests that return JSON and allow requests from any origin.

GET /process/call/route-org/?id=ORG_ID
GET /process/call/route-person/?username=USERNAME
fetch('https://www.callbird.com/process/call/route-org/?id=YOUR_ORG_ID')
  .then(function (r) { return r.json(); })
  .then(function (data) {
    var canCall = data.status === 'online' && data.calls_enabled === true;
    console.log(canCall, data.status_text);
  });

route-person also accepts ?id=USER_ID instead of a username.

Response

{
  "status": "busy",
  "status_text": "Available in 20 minutes",
  "calls_enabled": true
}
Field Type Description
status string online, busy or offline. route-person can also return on_call.
status_text string The sentence we show visitors, such as "Available now", "Available in 20 minutes", "Currently on a call" or "Currently offline". Never empty. Show it as it is rather than writing your own from the other fields.
calls_enabled boolean false when the plan doesn't include instant video calls, the calls switch is off, or the account isn't active. Then nobody can call, whatever status says.

Only call it "available" when both agree: status is online and calls_enabled is true. Responses include other fields (videos, team members). Those can change without notice, so don't build on them. Checking every 30 seconds is plenty.

Callbird.open()

Opens a Callbird page from your own code, the same way a live button does. Needs the button script.

Callbird.open(pageUrl, mode)
document.querySelector('#talk').addEventListener('click', function () {
  Callbird.open('https://www.callbird.com/yourteam/', 'modal');
});
Parameter Type Description
pageUrl string Your team page or someone's own page. You can add ?ref= or signed visitor data.
mode string popup (default, a 440 × 720 window), newtab or modal

Call it from a click. Browsers block popups opened any other way. This opens the page; the visitor still presses the instant video call button on it.

The overlay

modal mode puts your Callbird page in an iframe in the middle of your page, over a dark background. It's up to 440px wide and 720px tall. Visitors close it with the × or by clicking the background.

Use modal if you want call events. The call runs inside your page, so your page hears them. In popup and newtab modes the call runs in another window and your page hears nothing.

Closing the overlay

There's no close method. The overlay is an element with the id callbird-modal-overlay, so remove it yourself:

var overlay = document.getElementById('callbird-modal-overlay');
if (overlay) overlay.remove();

Removing it during a call drops the visitor from the call. Wait for callbird-call-ended first.

Listening for call events

During an instant video call, Callbird's page sends messages to the top-level page with window.top.postMessage. You get them from a page embed, the corner widget, and a button in modal mode. Listen with a normal message listener:

window.addEventListener('message', function (e) {
  if (e.origin !== 'https://www.callbird.com') return;
  var d = e.data;
  if (!d || typeof d !== 'object' || typeof d.type !== 'string') return;
  if (d.type.indexOf('callbird-call-') !== 0) return;

  console.log(d.type, d.call, d.reason);
});

Console lines

Each event also writes one line to the browser console of the Callbird page: CALLBIRD_CALL_REQUESTED, CALLBIRD_CALL_ACKNOWLEDGED, CALLBIRD_CALL_START and CALLBIRD_CALL_END. Useful when an app wraps Callbird in a web view and can read the console but not messages.

Your page also receives Callbird's own messages for sizing the widget (for example callbird-resize). Only act on types that start with callbird-call-.

Event types

type Fields When
callbird-call-requested call The visitor allowed the microphone and the call was placed. Your team is being alerted.
callbird-call-acknowledged call Someone pressed "Be right there" in the dashboard or Slack. Optional: most calls skip it.
callbird-call-started call The visitor joined the video call.
callbird-call-ended call, reason The call is over, or never got going. See the reasons below.

call is a string ID for the call, the same in every event for that call.

reason values

reason Meaning
caller-left The visitor left the video call.
rep-left Your side left the video call, so it was ended for the visitor.
rejected "Can't take" before anyone answered. On a team page, once everyone has pressed it.
visitor-left The call ended during the wait: the visitor left the waiting screen, or nobody answered in time.
mic-denied The visitor didn't allow the microphone. No call was placed, so there's no call field.
sorry-page The visitor reached the "couldn't take your call" screen.

What a call looks like

Answered requested → (acknowledged) → started → ended with caller-left or rep-left
Nobody answered requested → ended (visitor-left) → ended (sorry-page)
Declined requested → ended (rejected) → ended (sorry-page)
Visitor gave up waiting requested → ended (visitor-left)
Microphone blocked ended (mic-denied) only
  • • A call can end with two callbird-call-ended events. Treat the first one for a call as final and ignore the rest.
  • • If we couldn't place the call at all, you may get only ended (sorry-page), with no requested before it.
  • • If instant video calls are off or the account isn't active, no call is placed and no events are sent.

Visitor data

If the visitor is logged in to your site, sign their details on your server and add them to the Callbird page address. When they call, your team sees the details with a Verified badge in the dashboard and Slack.

https://www.callbird.com/yourteam/?visitor_data=BASE64_JSON&signature=HEX_HMAC_SHA256

Fields

Field Type Required
timestamp integer Yes. Unix seconds, within 5 minutes of when the visitor calls.
name string No
email string No
company string No
phone string No
custom object No. Flat name and value pairs.

Not supported for the corner widget yet. Signing code in five languages, and where to get your secret key, is in Signed Visitor Data.

Styling

Live buttons are your own elements. The script adds a few hooks you can style:

[data-callbird-status="online"]
[data-callbird-status="offline"]
Set on the button after each check
.callbird-status-dot The dot the script adds at the end of the button. Hidden while offline.
[data-callbird-label], [data-callbird-sublabel] Elements whose text the script replaces
.my-button[data-callbird-status="online"] {
  background: #173300;
  color: #fff;
}
.my-button .callbird-status-dot {
  background: #d2f0ba !important;
}

Examples

A status line without our script

<p id="team-status"></p>

<script>
function refreshStatus() {
  fetch('https://www.callbird.com/process/call/route-org/?id=YOUR_ORG_ID')
    .then(function (r) { return r.json(); })
    .then(function (data) {
      if (data.error) return;
      var el = document.getElementById('team-status');
      if (data.calls_enabled !== true) {
        el.textContent = '';
        return;
      }
      el.textContent = data.status_text;
    })
    .catch(function () { /* keep the last text */ });
}
refreshStatus();
setInterval(refreshStatus, 30000);
</script>

Send call events to your analytics

<script>
var cbSeenEnd = {};
window.addEventListener('message', function (e) {
  if (e.origin !== 'https://www.callbird.com') return;
  var d = e.data;
  if (!d || typeof d.type !== 'string' || d.type.indexOf('callbird-call-') !== 0) return;

  // Only count the first "ended" for each call
  if (d.type === 'callbird-call-ended' && d.call) {
    if (cbSeenEnd[d.call]) return;
    cbSeenEnd[d.call] = true;
  }

  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    event: d.type,
    callbird_call: d.call || null,
    callbird_reason: d.reason || null
  });
});
</script>

Thank-you page after a call

<script>
window.addEventListener('message', function (e) {
  if (e.origin !== 'https://www.callbird.com') return;
  var d = e.data;
  if (!d || d.type !== 'callbird-call-ended') return;
  if (d.reason === 'caller-left' || d.reason === 'rep-left') {
    window.location.href = '/thanks-for-calling/';
  }
});
</script>

Errors

The status endpoints answer with an error field instead of a status when something is wrong:

{ "error": "Organization not found." }
Message Cause
An organization ID must be passed in the URL. route-org without ?id=
Organization not found. Wrong team ID
An id or username must be passed in the URL. route-person without ?username= or ?id=
No user found. Wrong username or user ID
  • • Check for data.error before reading status.
  • • The button script treats an error answer as offline. If the request fails altogether (no network), it keeps showing the last state.
  • • Call events never report errors. A call that couldn't start ends with sorry-page or mic-denied.