How to Enable AI with Secure Communications

Share this article

Artificial intelligence

This article was created in partnership with BlackBerry. Thank you for supporting the partners who make SitePoint possible.

Imagine a healthcare platform that designs the perfect treatment plan for a patient based on their medical history. Picture a chatbot that automatically generates legal appeals or resolves customer disputes in minutes.

This technology already exists today, and it is just the beginning. Alongside the Enterprise of Things, we are on the verge of a second revolution. Artificial intelligence will change everything, from how we protect ourselves from cyberattacks to how we go about our daily lives. And according to Tata Consultancy Services, 84% of businesses believe AI will be essential for businesses if they are not to fall behind.

Building A Smarter Enterprise – Artificial Intelligence and App Development

Application development will be the foundation of the move towards artificial intelligence. Businesses that integrate AI into their apps will be able to provide new services and a better, more personalized user experience. They will be able to gain deeper insights into how their customers think and act, and open new revenue streams through those insights.

Moreover, artificial intelligence will power new, transformative interactions between people, machines, and the Internet of Things.

Through AI-driven analysis, businesses will gain a deeper understanding of their market and their staff. Automation will allow workers to respond proactively to customer complaints or security incidents, boost productivity, reduce costs, and minimize employee error. And through machine learning, businesses will be able to make better, more informed decisions than ever before.

In time, people will demand such capabilities. Next-generation apps and services will be expected to not only support human-to-human interactions, but also human-to-machine and machine-to-machine interactions. Just as mobile apps are critical to business success today, artificial intelligence will be critical to success very soon.

Getting Past The Roadblocks to Enterprise AI

Though most businesses acknowledge artificial intelligence’s importance, AI remains elusive. The issue is primarily one of complexity and cost. In a 2017 study by Infosys, 72% of IT professionals found time constraints were a roadblock to AI adoption, while 71% referenced financial limitations. Resistance to change and a lack of clarity around AI’s value were also hindrances.

Even for businesses that manage to overcome those challenges, security remains a core issue. AI apps will routinely deal with sensitive data such as customer information, internal messages, login credentials, usage details, and even intellectual property. Left unencrypted, such services could leak that data into the wrong hands.

Communications Platform as a Service (CPaaS) tools are central to overcoming these challenges. By integrating real-time communications into their apps – and tying that functionality to its AI services – developers allow for better, deeper interactions between AI and user. More importantly, with the right CPaaS solution, they ensure those interactions are kept secure, and that the AI does not leak critical data.

How The BBM Enterprise SDK Makes Your Apps Smarter

Here’s where the BBM Enterprise SDK comes in for Android, iOS, and Web. A secure CPaaS platform built on BlackBerry’s strength in secure mobile messaging, it gives your developers everything they need to incorporate secure, enterprise-grade messaging functionality in their apps. You can use commonly used identity and user management providers to make development even easier.

More importantly, it offers several features that directly empower artificial intelligence:

  • Embedded voice, video, chat. Enable your users to reach out to anyone around the world and be reached they want, whether for emergency communications, peer-to-peer collaboration, or by receiving personalize support services.
  • Publish/Subscribe Services. Create channels which broadcast to subscribing users. This keeps them updated on all new activity in a collaboration space, whether by another user or from the machine-readable information your application consumes.
  • Chatbots and Routing Services. Provide real-time support for your users via a chatbot which can process their data, activity, and messages. This information is then used to route them to the correct contact.
  • AI-Driven Predictive Analytics. AI algorithms enable behind-the-scenes user empowerment, delivering relevant information to users when they need it. These include location-based alerts or suggested actions based on user behavior.
  • Secure IoT Data Sharing. Eliminate the worry of cached copies or “fingerprints in the cloud” that could compromise privacy while also supporting real-time data sharing across all endpoints – human and machine.

We suggest that you first download the free SDK and familiarize yourself with the BBM Enterprise SDK with Blackberry’s Getting Started Guide.

Now that you’re ready, let’s dive into some examples that can help you get started with your AI journey…

How to Create Data Streams via Whiteboarding

This example shows how you can send arbitrary data in a BBM Enterprise SDK chat to create a shared whiteboard that allows us to do the following:

  • Create new whiteboards with one or more users
  • Share pictures and markup
  • Clear the whiteboard

This example builds on the Basic Setup that uses Google OpenID Connect. Note: To use the Whiteboard example, you must complete the setup steps in the Prerequisites section.


Visit the Getting Started with Android section to see the minimum requirements.

To use this example, you must set up the following elements:

  • Local keystore file
  • Client_server_id
  • Your BBM Enterprise SDK user domain.

You can copy these elements from the google-services.json file, and paste them into the file. The values for these elements are as follows:

  • client_server_id = “client_info” : “client_id”
  • user_domain=”your user domain”


  1. The Google web documentation contains an error: when creating an OAuth 2.0 client, you also must create an OAuth 2.0 client with the Application Type set to Android. You will need to input the SHA of your own keystore to complete the client ID (see note 2). Once complete, remember to download the google-services.json file again.
  2. You must create your own signing key. The Whiteboard example is setup to use a single signing key for both debug & release. To create your own signing key, visit The SHA value is required to create an OAuth 2.0 client ID for a mobile device.

This application has been built using gradle 2.14.1 (newer versions have not been validated)

Getting Started

The BBM Enterprise SDK can be used to send more than just text messages. The BBM Enterprise SDK supports sending opaque JSON content within a chat message. This example sends pictures and simple markup to create a shared whiteboard experience.

Sending a Doodle

Doodles drawn by the user are sent in the data section of a ChatMessage. To send the doodle we convert the bitmap into a base 64 encoded string. The encoded image content, size and position are written into a JSON object. The JSON object is set in the ChatMessageSend.

Tip: ChatMessages can be up to 70KB in size, See ChatMessageSend#data

First compress the bitmap we captured of the users input and encode it as a base64 string. The bitmap is always compressed as a PNG first, if the size is still outside our bounds its compressed as a JPEG.

baos = new ByteArrayOutputStream();
Bitmap.CompressFormat format;
if (shrinkCount == 0) {
    format = Bitmap.CompressFormat.PNG;
} else {
    format = Bitmap.CompressFormat.JPEG;
bmp.compress(format, imgQuality, baos);

//before doing the base 64 first check the compressed bytes to avoid wasted effort creating larger base 64 copy
if (baos.size() < maxSize) {
    dataBytes = baos.toByteArray();
    dataEnc = Base64.encodeToString(dataBytes, Base64.DEFAULT);
    tooBig = dataEnc.length() > (68 * 1024);

Create a JSON object that includes the encoded image data and the size and position in the canvas.

//send the width to allow UI to determine size quicker than loading image
jsonObject.put(CHAT_MESSAGE_DATA_KEY_DOODLE_WIDTH, bmp.getWidth());
jsonObject.put(CHAT_MESSAGE_DATA_KEY_DOODLE_HEIGHT, bmp.getHeight());
if (bmp.getWidth() != startWidth || bmp.getHeight() != startHeight) {
    jsonObject.put(CHAT_MESSAGE_DATA_KEY_SCALE_TO_WIDTH, startWidth);
    jsonObject.put(CHAT_MESSAGE_DATA_KEY_SCALE_TO_HEIGHT, startHeight);

//for whiteboard let it know where to position
jsonObject.put(CHAT_MESSAGE_DATA_KEY_DOODLE_LEFT, (int) event.leftMostX);
jsonObject.put(CHAT_MESSAGE_DATA_KEY_DOODLE_TOP, (int) event.highestY);


Attach the JSON data we created and send the chat message with a custom tag.

ChatMessageSend messageSend = new ChatMessageSend(chatId, WhiteboardUtils.CHAT_MESSAGE_TAG_WHITEBOARD);
//Attach our custom data to the chat message;

Populating the Whiteboard

To populate the whiteboard with the doodle messages we iterate over the list of received chat messages in reverse creating a draw list. To avoid re-drawing chat messages we keep track of the last message drawn and only draw messages new messages. If we encounter a message with the tag CHAT_MESSAGE_TAG_CLEAR we can stop since earlier images would not be visible after the clear.

//build list to display
ArrayList<ChatMessage> toDisplay = new ArrayList<>();
int size = chatMessageList.size();
boolean rememberLastDisplayed = true;
int pendingChatMessages = 0;
//start at last, go until find last displayed or control message
for (int i=size - 1; i >= 0; --i) {
    ObservableValue<ChatMessage> observableChatMessage = chatMessageList.get(i);
    ChatMessage chatMessage = observableChatMessage.get();
    if (chatMessage.exists == Existence.MAYBE) {
        rememberLastDisplayed = false;
        if (pendingChatMessages > 3) {
            //when the chat is first loaded all messages except the last one will be loading
            //if we continue we would process all previous messages, causing them to all load which
            //would display starting to draw recent messages, so stop after a reasonable amount to
            //give the most recent ones a chance to load so we can look for the last reset
    } else {
        if (Equal.isEqual(chatMessage, mChatMessageListLastDisplayed)) {
            //we already displayed this one, stop
        } else {
            String tag = chatMessage.tag;
            if (WhiteboardUtils.CHAT_MESSAGE_TAG_WHITEBOARD.equals(tag) || WhiteboardUtils.CHAT_MESSAGE_TAG_PICTURE.equals(tag)) {
            } else if (WhiteboardUtils.CHAT_MESSAGE_TAG_CLEAR.equals(tag)) {
                //last one
            //ignore others

Drawing the doodles or pictures requires us to recreate a bitmap from the base64 encoded data in the chat message. The size and position metadata included in the message are used to position the bitmap within the canvas.

if (WhiteboardUtils.CHAT_MESSAGE_TAG_WHITEBOARD.equals(tag) || WhiteboardUtils.CHAT_MESSAGE_TAG_PICTURE.equals(tag)) {
    if ( == null) {
        Logger.w("missing data for ID="+chatMessage.messageId+" tag="+tag+" ");

    Bitmap bmp = WhiteboardUtils.createBitmap(chatMessage);

    if (bmp == null) {
        Logger.e("Failed to create bitmap from "+chatMessage);

    //figure out if need to scale it
    int remoteWidth =, -1);
    int remoteHeight =, -1);

    Rect toRect;
    float scaleX = 1;
    float scaleY = 1;
    if (remoteWidth > 0 && remoteWidth != w) {
        //remote is different size
        scaleX = (float)w / (float)remoteWidth;
    if (remoteHeight > 0 && remoteHeight != h) {
        //remote is different size
        scaleY = (float)h / (float)remoteHeight;

    int left =, 0);
    int top =, 0);

    int rectX = (int)(scaleX * left);
    int rectY = (int)(scaleY * top);
    toRect = new Rect(rectX, rectY, rectX + (int)(scaleX * bmp.getWidth()), rectY + (int)(scaleY * bmp.getHeight()));

    canvas.drawBitmap(bmp, null, toRect, null);

Clearing the whiteboard

To clear the whiteboard of any existing doodles we send another chat message with the tag “ClearScreen”. When we encounter a clear tag we’ll wipe the canvas.

} else if (WhiteboardUtils.CHAT_MESSAGE_TAG_CLEAR.equals(tag)) {
    //clear canvas
    int color = Color.WHITE;
    if ( != null) {
        color =, color);


Get More Sample Applications

Click here to access the sample applications for a chat bot, rich chat, whiteboard, location sharing, and more – to help you build your next-generation Android, iOS, or JavaScript app.

Let’s Take a Closer Look into BBM Enterprise SDK

BBM Enterprise SDK presents enterprises and developers with a framework to develop real-time, end-to-end secure messaging capabilities in their products or services, including Android, iOS, Node.js, and Web.

With our communications platform, the possibilities are endless. With rich next-generation technologies, it powers your apps today—and in the future.

BBM secure messaging platform for developers

How Does it Ensure Security?

BBM Enterprise SDK’s security model ensures that data is protected both at-rest and in-transit, and encrypting instant messages, voice calls, and video calls. Only the sender and intended recipients can see each message sent, and ensures that messages aren’t modified in transit between the sender and recipient.

The BBM Enterprise SDK was designed to comply with the following three security principles:

  • Messages are* digitally signed*, so you’re assured of who sends each message in your application.
  • Messages are* encrypted*, so you’re assured that only the intended recipient can read the message.
  • Messages are* subjected to integrity signature checks*, so you’re assured the message isn’t modified in transit.

BBM Enterprise SDK uses a lot of security keys:

  • User’s Identity Keys
    • Public and private encryption keys for each user of BBM Enterprise SdK used to generate encryption keys for messages exchanged between two users outside of a chat (identity messages).
    • Public and private signing keys for each user of BBM Enterprise SDK used to digitally sign chat messages when sent, and verifying the signature when received.
  • Chat Keys
    • Symmetric encryption key for each chat, used to generate a per-message encryption key.

But your application has complete control over your security keys to keep your sensitive data private. BlackBerry does not have access to your keys and your application will share and distribute keys only between your users.

BBM key management

User Management

With the BBM Enterprise SDK, your application will have complete control over discovering and managing users and relationships, as user accounts in the BBM Enterprise SDK represent users in the SDK only.

Applications can also reuse existing user accounts and social networks by associating application accounts with BBM Enterprise SDK accounts

BBM User database

Build AI into Your App Today — For Free

Artificial intelligence will soon have a critical role to play in enterprise. Businesses that leverage it now will enjoy a considerable competitive advantage once it becomes more widespread. BlackBerry knows this – and we’re prepared to help your organization branch out into artificial intelligence, the enterprise of things, and whatever lies beyond.

For more information about the BBM Enterprise SDK, click here, or download the free SDK to start building apps right away.

David WisemanDavid Wiseman
View Author

David Wiseman is head of the global product and field marketing teams at BlackBerry. In his role, David oversees worldwide product positioning, product messaging, product marketing strategy, go-to market strategy, demand generation programs and pipeline development for BlackBerry’s enterprise software and services. Join the community and share your thoughts at the BlackBerry Developer Community. Check out what we are up to on the BlackBerry Developer Blogs.

aiAngelapapp designapp developmentArtificial Intelligenceblackberryenterprise applicationssponsored
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week