To run the Einstein Bots SDK, add this POM dependency to your pom.xml. For <version>, use the latest Einstein Bots SDK Java version.
<dependency>
<groupId>com.salesforce.einsteinbot</groupId>
<artifactId>einstein-bot-sdk-java</artifactId>
<version>${einstein-bot-sdk-java-version}</version>
</dependency>
Then set up these configuration variables.
private final String basePath = "BOT_RUNTIME_URL";
private final String orgId = "YOUR_ORG_ID";
private final String botId = "YOUR_BOT_ID";
private final String forceConfigEndPoint = "MY_DOMAIN_LOGIN_URL";
private final String loginEndpoint = "SALESFORCE_LOGIN_END_POINT";
private final String connectedAppId = "YOUR_CONNECTED_APP_ID";
private final String secret = "YOUR_CONNECTED_APP_SECRET";
private final String userId = "YOUR_SALESFORCE_LOGIN_USER";
private final String privateKeyFilePath =
"/path/to/YOUR_CONNECTED_APP_PRIVATE_KEY.der";
Here’s how you find the configuration values.
basePath: The runtime base URL found in the Add Connection dialog when you add the connected app to the bot. See Get Started with Einstein Bots API.orgId: The 18 character org ID of the Salesforce org that is associated with the bot. To get the org ID:- Find your Salesforce Organization ID (15 characters long).
- Then convert it from the 15 to 18 character version. You can find Salesforce org ID converters using any search engine.
botId: The bot ID found on the Bot Overview Page.forceConfigEndPoint: The forceConfig endpoint found in the Add Connection dialog when you add the connected app to the bot. See Get Started with Einstein Bots API.loginEndpoint: The Salesforce login endpoint. This ishttps://login.salesforce.comfor the production org andhttps://test.salesforce.comfor a sandbox org.connectedAppId: The consumer key of your connector app setup.secret: The consumer secret of connector app setup.userId: The user ID that you use to log in to Salesforce.privateKeyFilePath: Required for the JTW bearer flow. The private key that you used to create the public certificate and uploaded to the connected app for the OAuth 2.0 JWT Bearer Flow for Server-to-Server Integration. If your private key is inPEMformat, convert it to a DER format using this command.
openssl pkcs8 -topk8 -inform PEM -outform DER \
-in server.key -out src/test/resources/YourPrivateKey.der \
-nocrypt.
NOTE: The private key is required only for the JWT bearer flow. If you aren’t using the JWT bearer flow, provide your own authorization mechanism.