Tuesday, 29 August 2017

Get Started with Salesforce Einstein Vision Setup ๐Ÿ‘จ‍๐ŸŽ“


Last year in #DF16, Salesforce announced their new feature called SalesforceEinsteina new AI (Artificial Intelligence) platform built into the very core of Salesforce CRM platform. The basic purpose of this new feature is to deliver advanced AI capabilities to sales, service, and marketing- which will enable anyone to use clicks or code for building AI-powered apps that will get smarter with every interaction.

Signup with your Salesforce Einstein Account

1. Go to the sign-up page at https://einstein.ai/. You will get the free sign-up in the right most corner at the top.

2. Once you click on the free sign-up, this page will be opened. Join the Einstein platform by either using your salesforce account or Heroku account.

3. Once you click on sign-up using Salesforce, it will ask for your salesforce account.

4. Click Allow so the page can access basic information, such as your email address, and perform requests.

5. On the activation page:
  • if you are using Google Chrome (supports only latest version), just click on Download Key to save the key locally.The key file is named einstein_platform.pem
  • if you are using any other browser, cut and paste your key from the browser into a text file and save it as einstein_platform.pem

6. You can upload this Key into your org so that Apex controller class can access it. For this you have to login into your Salesforce org which you have used during the account signed up. After the select Files, then click on Upload Files button and upload the key file which you have downloaded.

Generate a Token

Each API call must contain a valid OAuth token in the request header. To generate a token, you create a JWT (JSON WEB TOKEN) payload, sign the payload with your private key, and then call the API to get the token.To get a token without code, we can also Setup Authorization.

Steps to setup Authorization:

1. Use this token page to upload your key file and generate a JWT token.
2. Type your Email Address or Account Id. If you signed up using Salesforce, use your email address associated with that org. Or if you signed up using Heroku, use the Account Id contained in the EINSTEIN_VISION_ACCOUNT_ID config variable. 

Click on choose file and select the key from your laptop which you have downloaded when you signed up for an account. You can set the number of minutes after which the token expires.Then click on Get Token button, you will get the token key.

Get the Code

To get the code, first you need to create account on Github (if you don't have account). Now you can get all the code in the Github.Once you created the account, follow these steps to download and clone the code from the Github:

1. Open this url for JWT repo: https://github.com/salesforceidentity/jwt

2. Click on Clone or download button.
3. Select Download ZIP to download the classes that handle the  JWT (JSON WEB TOKEN).
4. Again, open this url for Apex code repo: https://github.com/MetaMind/apex-utils
5. Repeat step 2 & 3.

If you already have installed Github, you can directly clone the repos using git bash.

Create your Remote Site Settings
Create a new Remote Site Setting as shown below and use this as Remote Site URL: https://api.metamind.io

You are done with the setup. Now you can write your Apex class and their related Visualforce pages into your org.
If you get stuck while setting up, check out the Einstein Platform Services developer forum on Salesforce Developers.

Related Information

1. Trailhead Project: Quick Start: Einstein Vision