In this blog, I am going to explain how to use salesforce Einstein Intent. Einstein Intent Categorize unstructured text into user-defined labels to better understand what users are trying to accomplish. You can use Einstein Intent API to analyze text from emails, chats, or web forms and many other use cases like
Determine what products prospects are interested in and send customer inquiries to the appropriate salesperson.
Identify topics across unstructured text in emails, meeting notes, or account notes to summarize key points.
Route service cases to the correct agents or departments, or provide self-service options.
Understand customer posts to provide personalized self-service in your communities
Salesforce Einstein Platform Services APIs user OAuth token for authenticating. To generate a token, you create a JWT payload, sign the payload with your private key, and then call the API to get the token. So you need to get your own einstein_platform private key. please follow this steps to get your einstein_platform key.
Refer this link for more information on the above steps.
Create custom metadata type or custom setting whatever works for you here to store the service endpoint, token endpoint and account details. Below is the custom metadata type which we are going to use it in this blog post.
Let’s Get Started.
As we are going to user cURL for model upload and training, we need to Generate a token for authentication. Go to this link and generate the token as shown below. We are going to use this generated token for model upload and train the model for predictions.
Remote Site Setting
Add remote site setting as shown below.
Step 1: DEFINE YOUR CLASSES AND GATHER DATA
In this step, you define the labels that you want the model to output when text is sent into the model for prediction. Then you gather text data for each of those labels, and that text is used to create a model.This is typically the most time-consuming part of the process. To make it easier for you to go through these steps, we provide a case routing .csv file that you can use.
The labels in the case routing dataset define the intent behind the text. The intent can then be used to route that case to the right department. Those labels are:
STEP 2: CREATE THE DATASET
In this step, you use the data you gathered to create a dataset. In the following command, replace with<TOKEN> your JWT token and run the command. This command:
Creates a dataset called case_routing_intent from the specified .csv file by accessing the file via a URL
Now you need to train your data set to create prediction ready model. Use this command to train the dataset and create a model. Replace <TOKEN> with your JWT token and <DATASET_ID> with ID of the dataset you created
Now your model is ready to go! To test it out, send some text in for prediction. This cURL call takes the ofmodelId the model from which you want to return a prediction and the text string to analyze. Replace with<TOKEN> your JWT token and with<MODEL_ID> the ID of your model.
curl -X POST -H "Authorization: Bearer 7KQH5DBEZNE2Z3H5L55I4POCYTAB3GMTSDA6HV264XGDGDSQGJACCO7M4DF5DTDGTDJI37WR4NGEPNFJZCGRGS2IBDRWF5OHIXF3SPY" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "modelId=PF4WICRUGR2BOO7QJ5MESD56MU" -F "document=how is my package being shipped?" https://api.einstein.ai/v2/language/intent
The response looks like this JSON. The model predicts that the text indicates that the user has a comment or question about shipping, so the model returns asShipping Info the top probability. Your app can then use this information to route the case to the right department or agent.