top of page

Future of Apex and AI in Salesforce : Einstein Apex AI Tools

Apr 2, 2020
2 min read

Hola! 😀

Today I am very excited to share some cool and exciting stuff and I’m sure you’re gonna love it!

There is very loud buzz of Artificial Intelligence, not just within the Salesforce Community but all around the globe, and it is certainly the one of the next big things!

There are already a lot of Salesforce Einstein AI based features that are currently available, for example, Prediction Builder, Einstein Bots, Natural Language Processing, Image Classification etc.

Now let’s dig a little deeper to understand how Salesforce Developers are using these features to build in-house apps.

Existing Practices to build AI based applications in Salesforce

At present, the platform doesn’t provide any out of the box machine learning capabilities which developers can use to power their applications with AI.

So as a general practice, we integrate the platform with external APIs which requires a lot of work for developers which involves writing Apex to do callouts to APIs, writing tests, error handling etc. Additionally, this involves account registration, authentication, setup, vendor maintenance and other operational overhead. And depending upon the use case, it may or may not involve creating datasets and training models. To me that’s an awful lot of work! 😫

Take calling a Language Processing API for example. The following is an example code snippet you would have to write:

public class TranslationCallouts { public static string makeCallout(String text) { String stringToTranslate = 'Thanks'; HttpRequest req = new HttpRequest(); Http http = new Http(); String url = 'https://www.languageprocessing.api/service/'; req.setMethod('GET'); req.setBody(text); req.setEndPoint(url); HTTPResponse response = http.send(req); // If the request is successful, parse the JSON response. if (response.getStatusCode() == 200) { // Parse and return callout response } else{ // Handle exceptions } }}

In practical implementations, the number of lines in the code are much more than this.

Now here comes the interesting part!

Apex AI Services(in pilot)

What if I told you you can replace the code snippet we just saw with a single line of code. No callout, no separate authentication, no registration, no setup, no fuss. All the ML capability available as a first class Apex method!! Mind blown, 🤯?

Calls for a Dab!

Looking forward to see your Dab GIFs on Twitter!

So yes, the new Apex AI Services provides a new namespace called AITools that provides classes and methods for Apex AI Services like OCR, Translation, Language Processing etc.

For example, to analyze sentiment of text, your code would simply look like this:

public void analyzeSentimentExample(String inputText) { String modelId = 'SomePrebuiltSentimentModel'; String language = 'en'; // Use English for sentiment analysis String detectedSentiments = AITools.MLServices.analyzeSentiment(inputText, modelId, language);}

Isn’t this amazing? Feel free to share your thoughts on this 😀

I will be exploring and sharing more on this pilot and the current capabilities of Apex AI Services through my future posts. Feel free to subscribe to this blog if you don’t wanna miss the updates!

How do I learn more?

This program, Apex AI Services, is currently in pilot. You can get nominated for it via your Account Executive.

Hope you enjoyed it. See you in the next one! ✌

 
 
 

Comments


bottom of page