Zero-Download Mobile Apps Powered by CPaaS

Image for zero-download mobile apps

A while back, “There is an app for that” was all the rage.  Today, the evolution of CPaaS is opening new pathways for customers and employees to interact with businesses.  Now the phrase has become a question, “Do we need an app for that?”. For many situations, the answer may be “no.”

The Trouble with Traditional Mobile Apps

Developing, testing, securing, distributing, maintaining, and supporting any software application can be a very costly endeavor in both time and resources.  Mobile apps are no exception. Coupling these costs with the added user burden of downloading, installing, and executing leads to a lack of user adoption and a lack of value added for the business.  With a growing resistance to downloading and installing mobile apps, businesses need new conduits to their users – conduits that don’t require cellular data or WiFi. Enter CPaaS.

But wait!  An application that uses CPaaS also takes resources to develop and may cost money to use.  So what’s the big advantage?

While there are still development costs involved with CPaaS solutions as well as user experience considerations, those costs and considerations are generally much lower due to the simplicity of using modern CPaaS.  Voice and messaging applications are generally much easier to design and deliver because they have common user interfaces such as voice calling and text messaging. People already familiar with using a smartphone are automatically familiar with your application’s interaction points.  The outcome is less cost to deliver the app and less learning curve for the end user.

Traditional mobile apps have their place in the world, but that place is shrinking.  Furthermore, a traditional mobile app is at higher risk of non viability. Despite the resources burned to produce and maintain the app, there is no guarantee anyone will actually download and use it.  CPaaS applications, on the other hand, are generally pay as you go once developed. They are easier to maintain and they are much easier to use leading to a better experience overall.

Apps Appropriate for CPaaS

It can be argued that any application could be driven by a voice or text messaging interface, but I doubt anyone would want to use voice to draw with a visual design tool or use text messaging to control an augmented reality game.  Applications that rely on real-time graphics or have complex user experiences are probably not appropriate for CPaaS interfaces. Applications that notify, share information, perform queries, manage proximity, provide support, or otherwise send and receive transactional data are more likely candidates for CPaaS.

Another compelling reason to use CPaaS is that in many cases it allows the user to interact online without using cellular data.  As an example, a CPaaS app allows a user to stream audio via a voice call instead of via an app using cellular data. Another example would be a CPaaS app that lets a user query parts of a database via text message instead of via a native or web app using cellular data.

Example CPaaS Application Using Bandwidth Messaging and Microsoft Cognitive Services

The code example below uses your smartphone’s standard text messaging interface to guess the contents of an image.  As we can see, the code to do this is much smaller than a web or mobile app would be because there isn’t any user interface or user experience to worry about.  That is all handled by the common interfaces already provided by the device.

To use this example, simply snap a photo and text it to (336)283-7944 or put the script below on your own Node.js server and use your Bandwidth number associated with an application that has the messaging callback pointed to your server’s URL:

//Visual Recognition Example using Bandwidth Messaging and MS Cognitive Services
//dapereira@bandwidth.com
 
//Import required npm packages
var Bandwidth = require("node-bandwidth");
var express = require("express");
var app = express();
var bodyParser = require("body-parser");
var fs = require("fs");
var cognitiveServices = require("cognitive-services");
var http = require("http").Server(app);
var url = require("url");
var path = require("path");
 
//Create a Bandwidth client object
//User ID, Token & Secret are found by logging into app.bandwidth.com and clicking “Account”
//These authentication values should be stored in environment variables for security purposes.
var client = new Bandwidth({
    userId: "YOUR_ BANDWIDTH_USER_ID", 
    apiToken: "YOUR_BANDWIDTH_API_TOKEN",
    apiSecret: "YOUR_BANDWIDTH_API_SECRET"
});
 
//Setup body parser
app.use(bodyParser.urlencoded({
    extended: true
}));
 
app.use(bodyParser.json());
 
//Route to send message callback
//Fetches media, creates MS Cognitive Client, Calls describe on image
//Formats and posts results as a text message
app.post("/describe-image", function(request, response) {
    console.log(request.body);
    if (request.body.media) {
        var parsed = url.parse(request.body.media[0]);
        var filename = path.basename(parsed.pathname);
        client.Media.download(filename).then(function(media) {
            fs.writeFile("<PATH_TO_MEDIA_LOCATION>" + filename, media.content, 'binary', function(err) {
                if (err) {
                    console.log(err);
                } else {
                    const parameters = {
                        "maxCandidates": "1"
                    }
 
                    const headers = {};
 
                    body = {
                        "url": "<URL_TO_MEDIA_LOCATION>" + filename
                    };
                    
                    var cvClient = new cognitiveServices.computerVision({
                        apiKey: "<YOUR_MICROSOFT_COGNITIVE_API_KEY>",
                        endpoint: "southcentralus.api.cognitive.microsoft.com"
                    })
                    
                    cvClient.describeImage({
                        parameters,
                        headers,
                        body
                    }).then(res =>{
                          client.Message.send({
                              from : request.body.to, //your bandwidth number
                              to : request.body.from, //number to send to
                              text : "I am " + Math.round(parseFloat(res.description.captions[0].confidence) * 100) + "%
 sure it is " + res.description.captions[0].text + "."
                          });
                    });
                }
            });
        });
    } else {
        client.Message.send({
            from : request.body.to, 
            to : request.body.from, 
            text : "I only work with images.",
        })
    }
});
app.listen(8080);

Bandwidth Getting Started Guides can be found here: https://dev.bandwidth.com