For my project, I collaborated with an interdisciplinary team which aimed to explore use cases for the adoption of AI and ML within the FinancialForce Workflows and Products. My task was to work with a demo from Salesforce Einstein. Currently, Einstein contains a large array of artificial intelligence features for customer resource management (CRM), essentially like a “pocket data scientist” so to speak. The demo I worked with contained two natural language processing APIs, Einstein Sentiment and Einstein Intent. My job was to package the two APIs for integration into PSA for exploration into use cases.

The Sentiment API analyzes text and then outputs percentages rating whether the given text was positive, negative, or neutral. I utilized the Case object as an example of how Sentiment could be used. I created custom number fields in the Case object called Sentiment positive, negative, and neutral.


I then created a process in process builder that would trigger every time a case comment was created or edited. The process would call a wrapper Apex class I built that would make an HTTP callout to the Sentiment API and use the case comment text for sentiment analysis.


The Sentiment API outputs the probabilities of whether the given text was positive, negative, or neutral in JSON. I parsed the JSON for the probabilities and populated the corresponding sentiment fields with them using Apex code.


The Einstein Intent API analyzes the intent behind a given piece of text based on a model trained from a given dataset, and returns the probability of the intent behind that piece of text being whatever labels are in your dataset. I used the Case object again to showcase the Intent API. For this example I used the example dataset Salesforce provides, which has labels for password help, billing, shipping info, sales opportunity, and order change. Just like the Sentiment example, I created custom fields for each intent label.


This example was essentially the same as the Sentiment one. I made a process in process builder to trigger whenever a case comment was posted or edited, and the comment text would be sent to a wrapper Apex class that would call the Intent API and return the intent probabilities. I then had Apex methods to update the intent fields in the case with the returned probabilities. I also built a wrapper class containing methods to upload data and train models for using for prediction.


Both APIs definitely have the potential to create a smarter workflow for people handling cases since they will be able to prioritize cases based on sentiment or intent ratings. However, my code is compatible for use with any SObject, so there are so many more potential applications!