# SalesForce Custom App

## Objective

This document will demonstrate how easy it is to integrate Salesforce to the iX Hello platform and create methods to pull data.

## Pre-requisites

* **An active Salesforce Account**

An active Salesforce account is required for this integration. The skill will require the user to log into their Salesforce account.

If an account needs to be created, please follow the steps below:

To proceed with these steps, you should have all the pre-requisites satisfied. If you are missing something, please go back and make sure you satisfy all of them.

Once done, you are ready to get started using iX Hello platform with Salesforce.

The following shows the general steps/activities that will be carried out in setting up this integration. **Note:** It is advisable to use same email for signup across the 3 channels below. Step 1 -3 below are compulsory.

1. Set up Integration and connection to [Salesforce](https://docs.ixhello.com/ixhc/connections/salesforce) refer this document
2. Sign up for iX Hello platform using: <https://bots.ixhello.com/>&#x20;
3. Create a custom app in iX Hello
4. Publish the skill
5. Test the Lex

Before you proceed from here, please make sure that these prerequisites have been fulfilled.

Setup connection to Salesforce

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FIvWCKO7LHyk8sCsZP7bv%2Fimage.png?alt=media&#x26;token=833a0429-99bd-410a-b4f2-04d707c7c625" alt=""><figcaption></figcaption></figure>

1. On the resulting Connect External System Form, fill out the following details, and click on ‘Connect System’.

**Choose Connection**: SalesforceCustom

**System Instance Name:** Salesforce Demo

**Note:** If a SalesForce Account is running on customer domain tick “**Use Custom Domain**” checkbox and provide the custom domain URL. Also, if Sandbox account is used then tick “**Sandbox**” checkbox.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2F8Ct9hXL75MDDcSuMrbyn%2Fimage.png?alt=media&#x26;token=8db11e93-ced4-4d6a-8f0b-7dea646c0bc5" alt=""><figcaption></figcaption></figure>

Once you click on “**Connect System**” button, you will be redirected to the Salesforce login page as shown below. Enter your username and password and click on “**Login**” button.

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI4uUFLsF-8W7fWb%2F6.png?generation=1632819299093447\&alt=media)

Once you are logged in, Salesforce might show a screen with permissions options, allow it. You will be redirected to the platform with a success screen as shown below.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2F6XNouaHxIut2lfVUvD5O%2Fimage.png?alt=media&#x26;token=990bef7d-3855-448c-85d5-bfe97ff2926a" alt=""><figcaption></figcaption></figure>

Now, you have successfully integrated Salesforce with the platform.

1. Now Salesforce has been successfully integrated with the iX Hello platform. Now, click “**Return to Integration Configuration**” to return to the connections page. SalesForceCustom will appear in the list as shown below.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FvUcconV3NDWYcv1lAnRz%2Fimage.png?alt=media&#x26;token=f0a86a10-c83e-43e2-a632-67cbd27f6cd3" alt=""><figcaption></figcaption></figure>

## Create a custom App in&#x20;

1. &#x20;Fill following details in the Add Custom window and click ‘Save’.

**Name:** SalesForce Custom&#x20;

**Custom Skill Type:** Search

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FEVTYRI4rJ9RtwXlye2lE%2Fimage.png?alt=media&#x26;token=05fe55e5-459e-449e-addb-0707595c191c" alt="" width="375"><figcaption></figcaption></figure>

1. The following popup screen will appear, add following details and click on Save.

**Name:** SalesForce DataSource

**Integration Configuration: Select** Salesforce Integration Config created in Step 2.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FWMCw95ytf1jT0WKKmlZM%2Fimage.png?alt=media&#x26;token=44057367-c6d5-4d85-a43a-d0f7b9e38c55" alt="" width="375"><figcaption></figcaption></figure>

## Create Methods to fetch the data from Salesforce

1. Next step is to create Methods. Methods allows you to fetch data from Salesforce. The salesforce supported custom queries can be used to define the data to be fetched from the linked Salesforce account.
2. iX Hello platform currently supports following Salesforce methods:
3. Get All Objects
4. Get Object Fields
5. Get Object ById
6. Get Object All Records
7. Get SOQL Query Results
8. Create Object
9. Update Object
10. Delete Object
11. For this document, we’ll create only one method. Users can refer to the appendix to explore all other supported methods.

### Scenario/ Use Case (Contact Finder):

### Method: GetSOQLQueryResult

This method requires just one parameter. Please review the information below.

Parameters:

| SOQLQuery | <p>SELECT Id, FirstName, LastName,Phone</p><p>FROM Contact</p><p>WHERE FirstName='John'</p><p>and LastName='Bond'</p> | This is a standard Salesforce Object Search language (SOQL) query which you can use in different ways |
| --------- | --------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |

1. Other than these two parameters, provide following standard inputs:

| Method Name           | You can give any name. This name will be displayed in the methods list.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Request Type          | <p><strong>GetItems</strong></p><p>This is the method that you are using</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| Parameters            | As explained in the previous table                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| Result Type           | <p>ListOfRecords (Auto Selected)</p><p>It indicates that the method can return one or more records</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| Record Limit          | <p>Numeric value (e.g. 10)</p><p>If Method is returning larger number of records, then you can limit this result by providing this value.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| Record JsonPath       | <p>Each method returns data in Json format and to pick any specific information from the json, we need to specify the <em>Record JsonPath</em> so iX Hello platform will pick that data in consideration while displaying results.</p><p>Example: $.\[\*]</p><p>This selects all the records that is returned.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| Empty Result Template | <p>When the method does not return any data, this response will be generated. So, we can specify something like:</p><p>“Sorry, I could not find the contact details”</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Record Template       | <p>Let’s assume that the following json represents one record.</p><p>{</p><p> "attributes": {</p><p> "type": "Contact",</p><p> "url": "/services/data/v47.0/sobjects/Contact/0032w000002GFOVAA4"</p><p> },</p><p> "Id": "0032w000002GFOVAA4",</p><p> "FirstName": "John",</p><p> "LastName": "Bond",</p><p> "Phone": "(312) 596-1000"</p><p> }</p><p>In this example, Phone is at root level and can be accessed by {{Phone}}</p><p>So, record template can be written as</p><p><em>Phone number of {{FirstName}} {{LastName}} is {{Phone}}</em></p><p>So, when a method is executed, this will be displayed as,</p><p><em>Phone number of John Bond is (312) 596-1000</em></p><p>Note:</p><p>Anything written in between {{ }} is represented as a Json field and it’s case sensitive.</p><p>{{Phone}} is not same as {{phone}}</p> |
| Result Template       | <p>This indicates how method results should be represented.</p><p>Here you go, {{Records}}</p><p>Here, {{Records}} represents one or more records separated by a separator.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

#### Sample Response:

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI52hyLc44oW-Se9%2F15.png?generation=1632819299094316\&alt=media)

1. Now let’s us proceed back to method building in iX Hello. Click on ‘Create New Method’ and fill out following details in the Create New Method pop up.

**Name**: GetContactMethod

**Request Type**: GetSOQLQueryResult

**SOQL Query**: SELECT Id, Name, Phone FROM Contact WHERE Name='{{ContactName}}'

**Result Type**: ListOfRecords

**Record Limit**: 1

**Record JsonPath:** $.\[\*]

**Empty Result Template:** Sorry I could not find phone number for requested name

**Record Template:** Phone number for {{Name}} is {{Phone}}.

**Result Template:** {{Records}}

**Click:** Save

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI53frh1-6Jox3r5%2F16.png?generation=1632819299095038\&alt=media)

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI54HsLebON0tzfE%2F17.png?generation=1632819299097170\&alt=media)

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI55SCIueaAovB7-%2F18.png?generation=1632819299090038\&alt=media)

1. Before moving further, you want to test whether the method build is success, and the method is able to extract correct data from Salesforce or not. Click on ‘Test’ to test the created method.

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI56GkWHJhLSYUoX%2F19.png?generation=1632819299097122\&alt=media)

1. Now, to test the method, let us go back to the Salesforce portal and create a Contact.

## Create Intents

1. In the top menu tabs, select “**Intents**” and “**Create New Intent**”. Then select or enter the following:

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI5AnG1Dp6i9RgUI%2F23.png?generation=1632819299114176\&alt=media)

Fill following details and click on Save

**Name:** SearchContactIntent

**Intent Type:** Search

**Intent Action:** Executive Method

**DataSource:** Salesforce DataSource

**DataSource Method:** GetPhoneNumberByName

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI5ByYwqx4jNoT-7%2F24.png?generation=1632819299091393\&alt=media)

## Create Slots

1. In next step, we have to create Slots. Slots correspond to the parameters in SOQL query that we defined in the method screen. In the top menu tabs, select “**Slots**” and select “**Create New Slot**”.

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI5CztDwlBsTErLO%2F25.png?generation=1632819299098942\&alt=media)

Fill the following details.

**Note**: The Reprompt message is what Lex will ask if it can’t fill/resolve the person slot. Then select or enter the following:

**Name:** ContactName

**Slot Order:** Blank

**Reprompt Message:** What is the name

**Type:** Full name

**Custom Skill:** Salesforce Custom Skill

**Intent:** SearchContactIntent

**Click:** Save

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI5D3fTnUnl2ay8P%2F26.png?generation=1632819299090482\&alt=media)

## Create Utterance

1. Utterance are words spoken to launch specific intents. In the top menu tabs, select “**Utterance**” and select “**Create New Utterance**”. Now input or select the following:

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI5E8WV1LhwFALNH%2F27.png?generation=1632819299106507\&alt=media)

**Value:** What is the phone number of {ContactName}

**Custom Skill:** Salesforce Custom Skill

**Intent:** SearchContactIntent

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI5F5HC-oT4iTaDH%2F28.png?generation=1632819299073137\&alt=media)

## Create Input

1. In the top menu tabs, select “**Input**” and select “**Create New Input**”.

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI5GuXvwuLl_8LfX%2F29.png?generation=1632819299091256\&alt=media)

Fill the following details:

**Name:** SearchContactInput

**Custom Skill:** Salesforce Custom Skill

**Custom Intent:** SearchContactIntent

**Data Source:** Salesforce DS

**Data Source Method:** GetContactMethod

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI5HnQdMGo8iotCh%2F30.png?generation=1632819299097702\&alt=media)

Once the Input is created, click on **Manage Parameters**. You need to follow this step if you have defined Slot.

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI5ItCSdKzwx1g6w%2F31.png?generation=1632819299091455\&alt=media)

1. On the resulting screen, click on Input Parameter and add the following details.

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI5JydakcB0nnn-2%2F32.png?generation=1632819299106485\&alt=media)

**Input Parameter Name:** ContactName

**Parameter:** ContactName

**Data Type:** Text

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI5Km7MUbWGeqsTD%2F33.png?generation=1632819299095956\&alt=media)

## Publish to Lex

1. The next step is to Publish the app. Here, we are going to publish to Amazon Alexa.
2. To publish to Alexa, select “**Publish**” in the top menu tabs then click “**Add Skill Publishing**”. Then input or select the following:

![](https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fvoiceworx-ai-api%2F-Mkfb2fGFUClJTF_hH9h%2F-MkfbI5LTYxSNLOR3Ngg%2F34.png?generation=1632819299088543\&alt=media)

**External Skill Name**: SalesForce CRM Demo Skill. (This will be the name of the skill in Alexa. Therefore, make it unique and different from the names of your other skills in Alexa.)

**Skill Type**: Search

**Channel**: Amazon Lex

**Uncheck the following**: Require account linking, Auto Publish

**Optional**: Replace all placeholder values in all “Message”. Uncheck all the settings shown in the second image below.

**Click**: Save.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FmszR7YaL2KCNQcMVHYWt%2Fimage.png?alt=media&#x26;token=0f4c71eb-9518-4cba-9789-4bedf0d3bde0" alt=""><figcaption></figcaption></figure>

1. In the top menu tabs select “**Publish**” then click “**Publish to Alexa**”.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FqfE7jFSQuOv1GOxnAi3C%2Fimage.png?alt=media&#x26;token=63b53a5c-22e5-4345-861b-697d9592d720" alt=""><figcaption></figcaption></figure>

Once in Publish Skill to Amazon Lex select and do the following:

**Selected App**: Salesforce custom skill

**External App Name:** SalesForce CRM Demo Skill

**Amazon Lex Version:** V2

**Select Amazon Lex Account:** Select the Lex account setup by your admin or the one you set up in step 4 above.

**Click**: Publish To Amazon Lex

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FbJlhQrdlxZL6pP7YSFV6%2Fimage.png?alt=media&#x26;token=af06b31f-79aa-442b-8b11-fe15695045b2" alt=""><figcaption></figcaption></figure>

1. On the resulting screen, ensure that a success message shows for the publishing steps before clicking “**Test Lex**”. If success message not shown, click “**Go Back to App Publishing**” to fix any issue shown in publishing result.

<figure><img src="https://docs.ixhello.com/~gitbook/image?url=https%3A%2F%2F1107164708-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-M8XHvUsfyTUFLvToHqD%252Fuploads%252FIampOFmZFUvGcAJK2TNu%252Fimage.png%3Falt%3Dmedia%26token%3Dd48f36e4-f3c8-46bb-ad6d-93a59bfc943a&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=4afda379&#x26;sv=2" alt=""><figcaption></figcaption></figure>

Once clicked on "**Test Lex Bot**", you will be redirected to App Publishing screen, and the Test Bot will appear at the right corner showing the App name along with the welcome message:

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FAsJXgulofd3bPDwILltT%2Fimage.png?alt=media&#x26;token=5f5202f8-afde-44dc-b8f7-779f7197fe3e" alt=""><figcaption></figcaption></figure>

Congratulations!

You have successfully completed building a Salesforce Custom Skill.
