This message will self-destruct in five seconds.
Babel is an open source chat widget and API built on the PubNub Data Streams Network. Babel lets you send self-destructing messages and helps facilitate public key exchanges.
Author: Larry Wu

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
  1. <script src="pubnub.js"></script>
  2. <script src="cryptico.js"></script>
  3. <script src="babel.js"></script>

  4. <script>
  5. var babel = new Babel('me');
  6. </script>
Self-Destructing Chat in 2 Steps

Build your chat to use encrypted, self-destructing messages by simply:

  • Importing the Babel, PubNub, and Cryptico SDKs
  • Initializing an instance of Babel

It’s as simple as that to get started! For additional details to build this app, check out our five-part blog series.

Public Key Exchange

Babel uses 1024-bit RSA encryption to secure every message that it sends. You can get an object of all users and their respective keys using the listUsers() call or get your own Cryptico RSAkey with myKey().

Babel uses 1024-bit RSA encryption to secure every message it sends
Sending and Receiving Messages

The basic building blocks to sending and receiving Babel messages are:

sendMessage(recipient, message, ttl) This sends the message string to the recipient provided. The ttl specifies the number of seconds the message will be available before it self-destructs.
returnMessages() This call returns all messages that haven’t self-destructed yet.
onRecieveMessage(callback) This allows you to specify a callback that should be called when you receive a message.
Data Streams

PubNub Presence allows you to detect when users enter or leave your app. With Babel, you can find all users currently connected to your chat using the listUsers() call. The callback within onPresence(callback) will be called whenever a user joins or leaves. For a more detailed overview of the Babel API, check out the README on GitHub.

Online Presence Detection

Try PubNub Today

Try Our APIs