New IP Messaging Features: Reachability, Message Attributes, and Push Configuration

July 01, 2016
Written by
Billy Chia
Twilion

ip-messaging

Today, I’m excited to announce three new features for IP Messaging focused on making in-app chat a more engaging, context-rich experience:

All are available in the latest versions of the IP Messaging SDKs: JavaScript 0.10.6iOS 0.14.2, and Android 0.8.1.

Currently available in public beta, Twilio IP Messaging allows developers to easily add chat to any web or mobile app. Throughout the beta we have been listening to customer feedback and added the most-requested features to our roadmap. In this post I’ll share with you the three most recent features to ship, why we build them, and how you can use them to build rich chat experiences.

Reachability Indicator

Many chat apps have a “green dot” that indicates if a user is online or offline. For asynchronous conversation, this bit of information is quite useful. If a user is online, you can expect they’ll get the message immediately. If not, you know it’ll be some time before they log in and see the message.

At the same time, there are corner cases where online status can be more confusing than it is helpful. For example, a user may have the app in the background, so their status shows as “offline,” however, they are still reachable immediately via a push notification. This is why we devised the reachability indicator to convey more than online/offline status and give a better representation of reachability.

Now, the IP Messaging userInfo object [JS, iOS, Android] contains properties that show if a user is online or notifiable via push. A user may be offline and not reachable via push notification if they’ve disabled push or never enabled it in the first place. By creating an event handler in your app to listen for changes to the userInfo object you can get realtime notifications when a user’s status changes.

//function called after client init to set up event handlers
function registerEventHandlers() {
    //Register UserInfo specific event handler
    ipMessagingClient.on('userInfoUpdated', handleUserUpdate(user));
}

//function to handle any UserInfo updates
function handleUserUpdate(user) {
    //handle reachability indicator
    if (ipMessagingClient.reachabilityEnabled) {
        //call a function which will update the relevant UI elements to show the Reachability state for the User 
        renderUserReachability(user.online, user.notifiable);
    }
}

 

Message Attributes

One of the powerful features of IP Messaging is the ability to send not only chat messages, but also contextual data for rich chat experiences. For example, while shopping for headphones want to ask a retailer about a particular pair. While chatting with them, you drag-and-drop the headphones into the chat window. Normally this would share an image of the headphones. By embedding contextual information along with the chat message not only is an image sent, but also ratings, SKU, pricing and more. On the other side, the user receives this rich data object and can render the additional information right in the chat.

contextual-chat

When Twilio IP Messaging first launched this capability was exposed by serializing the JSON object into a string and sending that as the chat message. This required every message to be packaged before being sent, and unpackaged before being displayed. In order to simplify the pattern and provide a more efficient way to send contextual information we’ve provided message attributes.

Now, all of the top-level objects in IP Messaging; channels, users, and messages, have an attributes property that allow JSON objects to be stored with arbitrary data.

  • Channel attributes allow chat room topics and other metadata to be stored on the channel.
  • User attributes are for storing profile information such as a user’s alias or a link to their profile image.
  • Message attributes provide a way to send message-level metadata such as images, descriptions, and GPS coordinates.

Granular Push Notification Configuration

As you may know, IP Messaging comes with push notification support built-in. When a user has a mobile app in the foreground events are sent over websocket to the app SDK. When a user puts the app in the background, Twilio automatically sends push notifications instead (if they are enabled by the user.)

Previously, IP Messaging didn’t provide much control over which notifications could be subscribed to. Now, IP Messaging provides granular control of push notification configuration with 4 notification types that can be individually enabled or disabled:

  • New Message
  • Added to Channel
  • Invited to Channel
  • Removed from Channel

Additionally, message templates can be defined for each message type. The default invited to channel template is

${USER} has invited you to join the channel ${CHANNEL}

But you could update to say whatever you wanted. For example:

New Invitation

Invitation: ${USER} is asking you to join ${CHANNEL}

Yay! ${USER} wants you to join ${CHANNEL}

Push notifications built-in to IP Messaging are specifically designed for chat use-cases. If you are looking for a standalone notification product, check out Twilio Notify.

Thanks to all of you who provided great feedback during this beta and helped shape these additions to the product. If you are new to IP Messaging, you can get started now to make use of these new features. Use reachability indicator to know when users are online, send contextual data via message attributes, and configure push notifications per type. We can’t wait to see what you build!