In addition to being one of the biggest and best known telecom providers in the country (if not the world), AT&T also has an extensive library of public APIs that developers can use to build enterprise apps and solutions. Developers can now access those APIs natively from the Force.com platform with the new AT&T Toolkit for Salesforce Platform. The toolkit provides strongly-typed Apex wrappers for RESTful AT&T APIs like speech-to-text, SMS, location, payment and more.

The AT&T Toolkit for Salesforce Platform is available as an unmanaged package and so its easy to install and configure it in your DE or Sandbox environment. You can also peruse the entire code base for the toolkit on this GitHub repo. In order to use any of the AT&T APIs supported by the toolkit, you’ll first have to sign-up for a free AT&T Developer Account and create a new test application.

The toolkit currently supports the following AT&T APIs

  • SMS: You can use this API to send and receive SMS messages to/from an AT&T subscriber. For example, the following code snippet sends out an SMS to the owner of a new Case record (assuming that the owner is an AT&T subscriber).
    List<Case> cases = [select caseNumber,
                        	   TYPEOF Owner when User then MobilePhone end
                        from Case where id in :caseIds];
    AttClientCredentialsAuthorization auth =
             new AttClientCredentialsAuthorization(ServiceConstants.ScopeType.SMS);
    for (Case c : cases){
        if (c.Owner instanceof User && ((User)c.Owner).MobilePhone != null){
            AttSMSOutbox smsOutbox = new AttSMSOutbox(auth);
            AttSMS sms  = new AttSMS();
            String unformattedNo =
                 ((User)c.Owner).MobilePhone.deleteWhitespace().remove('(').remove(')').remove('-');
            sms.phoneNumber = unformattedNo;
            sms.messageText = 'New Case #'+c.caseNumber+ ' has been assigned to you';

            try {
                smsOutbox.sendMessage(sms);
            } catch (AttException ex) {
                System.debug('Error sending SMS:'+ex.getMessage());
            }
    	}
    }

Similarly, you can use the AttSMSInbox class in the toolkit to receive and process SMS messages sent to a particular AT&T mobile number.

  • MMS: Similar to the SMS use case, you can also use the toolkit to send and receive MMS messages to/from an AT&T number. The AT&T Multimedia Messaging Service (MMS) API moves beyond the text-only capabilities of SMS messaging and includes the ability to attach picture, audio and video files along with the text message.
  • Speech-to-text: Powered by the AT&T Watson? speech engine, the Speech API supports speech-to-text conversion. Here is a small snippet of how you can use the toolkit to pass along a .wav file to AT&T and get the transcribed text string in return.
AttClientCredentialsAuthorization auth =
             new AttClientCredentialsAuthorization(ServiceConstants.ScopeType.SPEECH);
AttSpeech speech = new AttSpeech(auth);
speech.speechContext = AttSpeech.SpeechContext.GENERIC;
speech.fileType = AttSpeech.FileType.WAV;
speech.fileBlob = new Blob(fileContent);

AttSpeechResult response = speech.convert();

AttSpeechResult.Recognition recogn = response.Recognition;
AttSpeechResult.NBest nbest = recogn.NBest[0];
System.debug('Transcribed text is:'+nbest.ResultText);

As a sample use case, you could develop a Visualforce based hybrid mobile application using the Salesforce Mobile SDK that allows users to record audio notes after a client meeting. That voice recording could then be converted into text using the AT&T Speech APIs described above and saved as Notes attached to the respective Account/Opportunity record.

  • WAP Push: The AT&T WAP Push API allows developers to send push messages to legacy device customers that have limited message content and formatting capabilities (i.e. non-smartphone users).
  • Device Capabilities: The AT&T Device Capabilities API enables authorized applications to get details from the network for a particular mobile device. Developers can find out the make, model, GPS/A-GPS compatibility, device browser and other information about the rendering AT&T device and customize their mobile application accordingly.
  • Location: The AT&T Location API enables authorized applications to query the location of AT&T Phone Numbers. The location is network based and so developers can even invoke this API from devices that have no GPS capabilities. Here’s a small snippet from an Apex Controller class that uses the Location API to determine the location of the mobile device that is rendering the respective Visualforce page.
AttLocation locationService = new AttLocation(auth);
AttLocationResult locationResult =
        locationService.getLocation(AttLocation.ServiceType.DEVICE_LOCATION,
                                   1000, //requested accuracy in meters
                                   AttLocation.Tolerance.DelayTolerant,
                                   3000); //acceptable accuracy in meters
AttCurrentLocation currentLocation = locationResult.getCurrentLocation();
System.debug('Latitude is:'+currentLocation.latitude+ ' Long is:'+currentLocation.longitude);
  • Payment: The Payment API provides developers and merchants with the ability to directly charge for digital services to an AT&T subscriber bill. A merchant can create new transactions and subscriptions, request the status of the transaction or subscription, and authorize refunds both for transactions and subscriptions. This API is a nice alternative to using vendors like PayPal for adding e-commerce features to your Force.com mobile application.

 

Some of the APIs described above (e.g. Payment and Location) require end-user authorization from the respective AT&T subscriber via an OAuth workflow. The AT&T Toolkit for Salesforce Platform includes an OAuth 2.0 implementation that makes this task very simple for developers. For example, if you want to use the Location API from your Visualforce page, simply have the Apex controller extend the AttConsentWorkflow abstract class that is part of the toolkit. You will need to implement some of the abstract methods included in that class (e.g. initialize() and execute()) and configure the AT&T application with the correct redirect URL, but the toolkit takes care of all the OAuth redirects and callouts and makes it relatively straightforward to obtain end-user authorization. Check out the OAuth section of the Developer Guide for additional details on how to implement the AT&T OAuth flow.

In order to help developers get up-to-speed with the toolkit, the unmanaged package also includes simple demo apps for all the AT&T APIs supported the toolkit. I would recommend looking at those demos (and perusing the respective codebase) as the best way to get started with the toolkit.

If the toolkit itches your creative bone (wart?) and you want to find out more, we’ll be in Las Vegas from Jan 5-7 at the AT&T Developer Summit demoing the toolkit. Drop by if you’re in town and we’ll be happy to discuss the toolkit in greater detail. In the meantime, rethink what’s possible using the new AT&T Toolkit for Salesforce Platform.

tagged , Bookmark the permalink. Trackbacks are closed, but you can post a comment.