Create a French Model

In this walkthrough, you use the Einstein Intent API to create a French model to route support cases. You can then use the model to analyze text and infer what the user wants to accomplish. You use the French case routing sample .csv file that we make available to you.

A valid JWT token is required to make API calls.

  1. Find your key file. If you already created an account, locate the einstein_platform.pem file that you downloaded as part of that process. This file contains your private key.

  2. Install cURL. You use the cURL command-line tool throughout the following walkthrough. The tool is installed by default on Linux and OSX. If you don’t already have it installed, download it from https://curl.haxx.se/download.html. Alternatively, you can use Postman to make API calls.

  3. Get a token. The Einstein Intent API uses the OAuth 2.0 JWT bearer token flow for authorization. Use the token page to upload your key file and generate a JWT token.

  1. Replace <TOKEN> with your JWT token, and run the following command from the command line. This command:
  • Creates a dataset called Dataset de Routage de Cas from the specified .csv file by accessing the file via a URL. If you leave out the name parameter, the dataset name defaults to the name of the file: case_routing_intent_fr.
  • Creates five labels as specified in the .csv file.
  • Creates 150 examples.

This call is asynchronous, so the response looks like this JSON.

  1. To verify that the data has been loaded, make a call to get the dataset. Replace <TOKEN> with your JWT token, and replace <DATASET_ID> with the ID of the dataset that you created.

The results look something like this JSON. You know the dataset is ready when available is true and statusMsg is SUCCEEDED. You can see that the response also returns the language field.

  1. In the following command, replace <TOKEN> with your JWT token, and replace <DATASET_ID> with the ID of the dataset that you created, and run the command.

The response looks like this JSON.

  1. Use the modelId to make this call and get the training status. Replace <TOKEN> with your JWT token, and replace MODEL_ID with the ID of the model that you created.

The training status response looks like this JSON. When status is SUCCEEDED, it means the training was successful, and the model is ready for predictions.

Now your model is ready to go. To test it, send some text in for prediction. This cURL call takes the modelId of the model from which you want to return a prediction and the text string to analyze. In this case, the string in English is, “I would like to buy a soccer jersey.”

  1. Replace <TOKEN> with your JWT token, and replace <MODEL_ID> with the ID of your model. Then run the command.

The response looks like this JSON. The model predicts that the text indicates that the user is interested in buying something, so the model returns Opportunité de Vente (Sales Opportunity) as the top probability.

Your app can then use this information to route the case to the correct department or sales person.