# IntentFeature BeforeAfterMethod

**Objective**

This guide will help to quickly understand a feature of the intent called Before Method and After Method. Usually, an intent executes a single method, however using the feature of before method and after method, you can configure an intent to execute multiple methods. This guide will help you to understand this.

### Pre-requisites <a href="#toc61458270" id="toc61458270"></a>

1. **An iX Hello Account**

For steps to create an iX Hello account, follow the steps at

[https://docs.ixhello.com/general/ixhello-create-account](https://docs.ixhello.com/general/voiceworx-create-account)

1. **An active AWS Account**

You should have an active AWS Account. If you do not have it, you can create an AWS account at <https://portal.aws.amazon.com/billing/signup#/start>

*AWS Accounts Include 12 Months of Free Tier Access*

1. **AWS Account - Access Key, Secret access key and AWS Region Name**\
   To be able to connect to Amazon Lex from the iX Hello platform, one AWS IAM user is required, and user should have the required permissions to access Lex service.

Following is a JSON document which you can use to create an IAM policy and assign it to the IAM user in the AWS console.

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "ixHello",
            "Effect": "Allow",
            "Action": [
                "lex:*",
                "lambda:*",
                "iam:*",
                "chime:*"
            ],
            "Resource": "*"
        }
    ]
}
```

For more information on creating IAM users and assigning policies, refer to the AWS official documentation <https://aws.amazon.com/premiumsupport/knowledge-center/create-access-key/>

You can also refer to the simplified iX Hello documentation at <https://docs.ixhello.com/aws-iam-users>

To proceed with these steps all pre-requisites must be satisfied. If something is missing, please return to pre-requisites to ensure all are fulfilled.

Now let’s begin using iX Hello platform with Amazon Lambda.

### Setup connection to Amazon Lex <a href="#toc61458271" id="toc61458271"></a>

1. Login to the iX Hello platform, use left navigation menu and click “**Integration**” then select “**Connect System”**. In the resulting page, click “**Add New Connections**”.

<figure><img src="/files/YxEV8R1gzd72bHEDvutq" alt=""><figcaption></figcaption></figure>

**Choose Connection: Amazon Lex**

**Click**: Next

<figure><img src="/files/2r8F2V41g9Ryak66ht66" alt="" width="563"><figcaption></figcaption></figure>

1. Once clicked in “**Next**” the configuration screen below will appear. Provide connection information as shown below:

* **Service Instance Name**: You can give any value of your choice.
* **Consumer Key**: This information is made available in pre-requisites #4
* **Consumer Secret**: This information is made available in pre-requisites #4
* **Region**: This information is made available in pre-requisites #4
* **Click**: Validate and Save Settings
* **See below additional information**.

<figure><img src="/files/8w4LWWbpxz650eN3Puq6" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/2N14QMvwFYuh7iLyFuHq" alt="" width="563"><figcaption></figcaption></figure>

The table below explains each of the inputs shown on this screen:

| Input                 | Information                                                                                                                                     |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| Service Instance Name | You can give any value of your choice.                                                                                                          |
| Consumer Key          | This is your AWS Access key ID                                                                                                                  |
| Consumer Secret       | This is your AWS Secret access key                                                                                                              |
| Region                | <p>AWS Region Name. The Lex service will be used in this region.</p><p>When used to publish the skill, it will be published in this region.</p> |

1. Once validation is confirmed the details of integration will be saved. The integrations listing page will be shown as below.

<figure><img src="/files/G0EMGS1N0aZYyn1MM7TL" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Uz4J04iem7dcQ3BppwTM" alt="" width="563"><figcaption></figcaption></figure>

Lex connection is ready to use for future usage.

### Create a new connection for the Internal Data <a href="#toc61458272" id="toc61458272"></a>

1. Create another connection for Internal Data. Internal Data means the data source that iX Hello provides by default.
2. Click on Add New Connection on the Connect System page from the left navigation.

You should see a small popup screen as shown below.

<figure><img src="/files/cTcVrVB2MVSfJVhlOis9" alt=""><figcaption></figcaption></figure>

1. Select Custom for the Integration Category
2. Select Internal Content for the System Type
3. Give any name of your choice for the system Instance Name.
4. Click on Connect System button and this should quickly create a connection for the internal Content for you.
5. You should see a newly created connection as shown in below screenshot.

<figure><img src="/files/8ghvUoPR6EB6IrA8z4U0" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/QGChW2zWyziI7lU0ojIW" alt="" width="563"><figcaption></figcaption></figure>

Now the connection is ready to use with the skill

### Create an App to utilize internal data <a href="#toc61458273" id="toc61458273"></a>

1. To create a skill, browse to Apps > Custom Apps and click on New Custom App button, you should see a small popup screen as shown below.

<figure><img src="/files/a4GiRLPQMKBksC7HgKjZ" alt="" width="320"><figcaption></figcaption></figure>

<figure><img src="/files/HGjcjKfhIFgcI1HD2IJc" alt="" width="320"><figcaption></figcaption></figure>

| Input                    | Information                                                                                                                                                                                         |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name                     | You can give any value of your choice.                                                                                                                                                              |
| Custom App Type          | Select Search                                                                                                                                                                                       |
| Category                 | <p>Please use the same category that you have used for the Intern Data.</p><p><strong>Note:</strong> If category do not match then methods in this app may not be able to access the JSON data.</p> |
| Make this app as shared… | Select this if you want to share this app with other users in your organization.                                                                                                                    |

1. Click on ‘Save’ and app should get created and selected for the next steps.

### Create a Content <a href="#toc61458274" id="toc61458274"></a>

1. Click on “**Content**” then select “**Content”**. In the resulting page, click “**Add New Content**”.

Fill in the details as explained below:

* **Content ID**: Contacts01
* **Content Name**: Contacts01
* **Category**: Which you would have created
* **Text**: Contactfinder
* **Media Type:** JSON

  Upload the JSON file as shown in the below screen:

<figure><img src="/files/ZYQIWv5uo85og0dj5xZQ" alt="" width="320"><figcaption></figcaption></figure>

### Create a Content <a href="#toc61458274" id="toc61458274"></a>

1. Click on “**Content**” then select “**Content”**. In the resulting page, click “**Add New Content**”.

Fill in the details as explained below:

* **Content ID**: Contacts01
* **Content Name**: Contacts01
* **Category**: Which you would have created
* **Text**: Contactfinder
* **Media Type:** JSON

  Upload the JSON file as shown in the below screen:

<figure><img src="/files/hZzluhRlNuheST2myQjx" alt="" width="320"><figcaption></figcaption></figure>

### Create a Data Source <a href="#toc61458274" id="toc61458274"></a>

1. A Data Source connects the app with the integration. Once you have an app created, you can go to Data Sources by clicking on “Data Sources” tab.

<figure><img src="/files/zTRbyNQqMRQ9y3VVqlkk" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/CiSYuYeXuauiBvq7lNll" alt="" width="563"><figcaption></figcaption></figure>

1. To create a data source, click on ‘Create New Data Source’ button and you should see a popup screen as shown below

<figure><img src="/files/j5JgRve116qi5N0ApBHd" alt="" width="320"><figcaption></figcaption></figure>

<figure><img src="/files/9lcbtPy58NEYAyXKzDUw" alt="" width="320"><figcaption></figcaption></figure>

1. Give a name of your choice and make sure you select the same connection that you have created in Step 2. In this example, it is “My Contacts”. If you want to make this connection as private to you, select the available option “Consider as a Personalized Data Source”. If selected, other users in your organization will not be able to use it.
2. Now click on Save. Once a data source is created, you are ready to start creating various methods and use JSON Data.

### Sample Data (JSON file): <a href="#toc61458275" id="toc61458275"></a>

1. We are going to use sample contacts data in JSON format. You should have a contact created with following JSON data.

```
{
  "Contacts": [
  {
    "name": "Martin",
    "contactnumber": "(678)345 6789",
    "country": "US",
    "occupation": "Businessman"
  },{
     "name": "Bob",
     "contactnumber": "(678) 045 6789",
      "country": "US",
      "occupation": "Engineer"
  },{
     "name": "James",
     "contactnumber": "(678) 123 0456",
     "country": "Canada",
     "occupation": "Teacher"
  }
  ]
}
```

### Create Methods <a href="#toc61458276" id="toc61458276"></a>

### Method-1: GetContactNumberMethod <a href="#toc46439382" id="toc46439382"></a>

1. Let’s created first method which returns contact number of a person.

For each of the inputs, enter values as shown below.

| Input                                        | Value                                           |
| -------------------------------------------- | ----------------------------------------------- |
| Method Name                                  | GetContactNumberMethod                          |
| Request Type                                 | GetJsonContents                                 |
| <p>Parameters</p><ul><li>ContentID</li></ul> | Contacts01                                      |
| Record Limit                                 | 10                                              |
| Record JsonPath                              | $.Contacts\[?(@.name=='{{Name}}')]              |
| Empty Result Template                        | Contact not found                               |
| Record Template                              | Contact Number of {{name}} is {{contactnumber}} |
| Result Template                              | {{Records}}                                     |

<figure><img src="/files/ERvzWgqSlUlxXSQD2XGL" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/cuwVXh1COMmdZCo3svBP" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/qsqCNiHDHR5Lc8jCkYGR" alt=""><figcaption></figcaption></figure>

Now click on Save & Test. Once you test this method, it should

<figure><img src="/files/zTzXpxZ9p49hHFaWJDY9" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/IXtpEZj8Irl685HIoZss" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/dJEMYwPpa0nGOEKlKbDV" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/ctqEgKLVdIZdfb3Bwr7U" alt="" width="563"><figcaption></figcaption></figure>

Now click on Save & Test. Once you test this method, it should

<figure><img src="/files/1DZcM60oOdJRHybauc5B" alt="" width="480"><figcaption></figcaption></figure>

#### Sample Response: <a href="#toc46439384" id="toc46439384"></a>

Contact Number of Bob is (678) 045 6789

### Method-2: GetLocationMethod <a href="#toc61458279" id="toc61458279"></a>

1. Let’s created another method which returns location of a person.

For each of the inputs, enter values as shown below.

| Input                                        | Value                              |
| -------------------------------------------- | ---------------------------------- |
| Method Name                                  | GetLocationMethod                  |
| Request Type                                 | GetJsonContents                    |
| <p>Parameters</p><ul><li>ContentID</li></ul> | Contacts01                         |
| Record Limit                                 | 10                                 |
| Record JsonPath                              | $.Contacts\[?(@.name=='{{Name}}')] |
| Empty Result Template                        | Contact not found                  |
| Record Template                              | {{name}} lives in {{country}}      |
| Result Template                              | {{Records}}                        |

#### Sample Response: <a href="#toc61458280" id="toc61458280"></a>

Bob lives in US

<figure><img src="/files/CO84TPzLGGcaO8gTAhmT" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/1J6LFvqAEIOz33rMX9oZ" alt="" width="480"><figcaption></figcaption></figure>

Method-3: GetOccupationMethod

1. Let’s created another method which returns occupation of a person.

For each of the inputs, enter values as shown below.

| Input                                        | Value                              |
| -------------------------------------------- | ---------------------------------- |
| Method Name                                  | GetOccupationMethod                |
| Request Type                                 | GetJsonContents                    |
| <p>Parameters</p><ul><li>ContentID</li></ul> | Contacts01                         |
| Record Limit                                 | 10                                 |
| Record JsonPath                              | $.Contacts\[?(@.name=='{{Name}}')] |
| Empty Result Template                        | Contact not found                  |
| Record Template                              | {{name}} is {{occupation}}         |
| Result Template                              | {{Records}}                        |

#### Sample Response: <a href="#toc61458282" id="toc61458282"></a>

Bob is Engineer

<figure><img src="/files/qwyi3aVBRAGArcG9mStm" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/dyK7i4qIKx4g7LHx8cLU" alt="" width="480"><figcaption></figcaption></figure>

### Create Intent <a href="#toc61458283" id="toc61458283"></a>

1. Now it is time to create one or more intents. For the demonstrate purpose, we will create one intent.
2. Navigate to the Intents tab and then click on Create New Intent button as shown below

<figure><img src="/files/fnr2UbwupOlOW1UhjLe2" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/F0qbOHDeW3g3SDGbrZxz" alt=""><figcaption></figcaption></figure>

### Primary method: <a href="#toc61458284" id="toc61458284"></a>

Normally an intent executes one single method called as Primary method. However, using a feature called Before Method and After Method, we can choose to execute additional methods.

If any session variable is defined or set for the before method, those will be accessible to the After method.

### Before Method (Optional): <a href="#toc61458285" id="toc61458285"></a>

If we select Before Method, we get an option to select a data source and a Method which gets executed just before executing the primary method. The result of this method is returned along with the result of the primary method.

If any session variable is defined or set for the before method, those will be accessible to the Primary Method and After method.

### After Method (Optional): <a href="#toc61458286" id="toc61458286"></a>

If we select After Method, we get an option to select a data source and a Method which gets executed just after executing the primary method. The result of this method is returned along with the result of the primary method.

It can access session variables defined in Before Method or in the Primary Method.

1. On the Intent creation screen, you should see a popup screen for creating intent. Provide inputs as shown below.

| Input                  | Value                                                   |
| ---------------------- | ------------------------------------------------------- |
| Intent Name            | GetOccupationIntent                                     |
| Intent Type            | Search                                                  |
| Intent Action          | Execute Method                                          |
| Before Method Checkbox | True                                                    |
| Data Source            | The data source that you want to use (Contacts in JSON) |
| Data Source Method     | GetLocationMethod                                       |
| Primary Method         |                                                         |
| Data Source            | The data source that you want to use (Contacts in JSON) |
| Data Source Method     | GetOccupationMethod                                     |
| After Method Checkbox  | True                                                    |
| Data Source            | The data source that you want to use (Contacts in JSON) |
| Data Source Method     | GetContactNumberMethod                                  |

<figure><img src="/files/IhEASm9ZktRLMZlwQECs" alt="" width="258"><figcaption></figcaption></figure>

### Create a slot <a href="#toc61458287" id="toc61458287"></a>

<figure><img src="/files/Qr3VVasuRLm2KiX5vOHk" alt="" width="387"><figcaption></figcaption></figure>

### Create a slot <a href="#toc61458287" id="toc61458287"></a>

1. We need to create a slot as the method we are using that uses one variable. Go to the Slots tab and select GetOccupationIntent from the intent dropdown.

<figure><img src="/files/ITclhGIy2ufv0uKnWv6o" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/ID5jTrvIXjfGdc8mFttN" alt="" width="563"><figcaption></figcaption></figure>

Now click on Create new slot button and you should see a add slot screen. Enter required values as shown below and click on save to create the slot.

<figure><img src="/files/l1NVdxBawu2mzkqIg3vj" alt="" width="389"><figcaption></figcaption></figure>

<figure><img src="/files/neRVEXEWVmCIiLeedtpu" alt="" width="260"><figcaption></figcaption></figure>

### Create Utterance <a href="#toc61458287" id="toc61458287"></a>

1. Now let’s create an utterance which we will be using from Lex to test the bot/skill

Go to the Utterances tab and then select the intent that we have already created, now click on Create New Utterance button.

<figure><img src="/files/tP0vWPocfrgJ5V6Yz2J1" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/1AmjU9872i3viLh5R0yC" alt="" width="563"><figcaption></figcaption></figure>

This should bring a create utterance screen. Enter the values as shown in below screenshot.

<figure><img src="/files/TP7gck3BieDnRCs0UkKh" alt="" width="320"><figcaption></figcaption></figure>

<figure><img src="/files/8rBTg8xFSfmHrfP24vC7" alt="" width="480"><figcaption></figcaption></figure>

Click on save and an utterance should get created.

You can also create/edit utterances in bulk; to do that click on "Bulk Edit" button, this should bring a bulk edit utterance screen. Enter the values.

### Create Input <a href="#toc61458289" id="toc61458289"></a>

1. The method we are using requires an input, so we need to create an input from the Inputs screen. Go to the inputs tab and then click on Create New Input button.

<figure><img src="/files/qkNBZKZuBPQ7UUBzwTqa" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/OAyeVmV16vZSwN19IxCj" alt="" width="563"><figcaption></figcaption></figure>

On the Add new Custom input screen, fill the details as shown below and click on save.

<figure><img src="/files/H4gKFKX9Mgk8uiligIt8" alt="" width="264"><figcaption></figcaption></figure>

<figure><img src="/files/kdIKce6IObDlBrNLdgwX" alt="" width="264"><figcaption></figcaption></figure>

Once saved, you should see input in the list.

### Create Input Parameter <a href="#toc61458290" id="toc61458290"></a>

1. On the inputs list, click on the Manage Parameter button in the Action column – as shown below.

<figure><img src="/files/mn3LR5pQNrXryMxOqyld" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/7AYjcWszUapEWArSFG7D" alt="" width="563"><figcaption></figcaption></figure>

Once you are in the Manage Input Parameters screen, click on "Input Parameter"

<figure><img src="/files/MpYLxvbL4ylt0mMNDvFj" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/WuyE2Q252UmwITJyLict" alt="" width="563"><figcaption></figcaption></figure>

1. On the Add input parameter screen, enter values as shown in the below screenshot.

<figure><img src="/files/CVOoT5sx3sAvituS7zJc" alt="" width="263"><figcaption></figcaption></figure>

<figure><img src="/files/UUcVSu0ukpHT60O11bin" alt="" width="394"><figcaption></figcaption></figure>

Click on Save and input parameter should get created.

Now we are ready to publish the skill on any platform.

### Publish to Amazon Lex <a href="#toc61458291" id="toc61458291"></a>

1. In the top menu tabs, select “**Publish**” then click “**Add Skill Publishing**”.
2. Once in “**Add Skill Publishing**” the popup screen will appear. Follow this documentation <https://docs.ixhello.com/skills/lex-publishing-auto-manual>

| External App Name | This is the name of the app. You can give name of your choice. |
| ----------------- | -------------------------------------------------------------- |
| App Type          | It should be “Search”                                          |
| Channel           | Must be “Amazon Lex”                                           |
| Auto Publish      | Keep it selected                                               |
| Welcome Message   | Should be auto populated.                                      |
| Re-Prompt Message | Should be auto populated.                                      |
| Help Message      | Should be auto populated.                                      |
| Goodbye Message   | Should be auto populated.                                      |
| Fall Back Message | Should be auto populated.                                      |

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

**App Description:** ContactFinder

**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="/files/sg4N1WkbNOFsbJtwLWWO" alt=""><figcaption></figcaption></figure>

1. Once in “**Publish**” the publish process is initiated. The screen shown below will appear.
2. Click “**Publish to Lex**” and this will initiate the publish process. The following results screen will appear as shown below.
3. The results screen has an option to go to the “**Go To LexV2 aPP**” or “**Go Back to App Publishing**”.

**Selected App**: ContactFinderDemo (Name of the App to be published in Lex)

<figure><img src="/files/3kNQFyRKsi0o1tElqeZE" alt=""><figcaption></figcaption></figure>

External App Name: ContactFinder

Amazon Lex Version: V2

**Select Amazon Lex Account: Lex Account details**

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="/files/EJtaLio33SoPDHYOqgQX" alt=""><figcaption></figcaption></figure>

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="/files/ovfw8UbDJEwqkZTLYcY8" 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="/files/rmwMbgUC7K31LnV1nWPM" alt=""><figcaption></figcaption></figure>

Query the bot with the Utterance “Can you give me the details of a person” and provide the name pf whom you would like to see the completed deatils, for ex : type “Can you give me the details of a person”. Bot will respond with a question: What is the contact name and then provide the name “James”, then you will see the entire details of James “ his name, contact number, location and occupation”

<figure><img src="/files/iJv89UvApsKkhBWG5mAv" alt="" width="320"><figcaption></figcaption></figure>

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

**App Description:** ContactFinder

**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="/files/cVnF0FGvXhNx2J65oWCq" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/I9tYgRPesPtwbxrIkEYQ" alt="" width="563"><figcaption></figcaption></figure>

External App Name: ContactFinder

Amazon Lex Version: V2

**Select Amazon Lex Account: Lex Account details**

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="/files/gTJPQa2PauydOGaozBfc" alt="" width="563"><figcaption></figcaption></figure>

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="/files/4NXqNwFMzoo9cyqIF9sD" alt="" width="480"><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="/files/RerWBlyozErUoUjVVrQa" alt="" width="563"><figcaption></figcaption></figure>

Query the bot with the Utterance “Can you give me the details of a person” and provide the name pf whom you would like to see the completed details, for ex: type “Can you give me the details of a person”. Bot will respond with a question: What is the contact name and then provide the name “James”, then you will see the entire details of James “ his name, contact number, location and occupation”

<figure><img src="/files/C1gGJPIIOej6MoRlSGdt" alt="" width="320"><figcaption></figcaption></figure>

Congratulations!

You have successfully completed Amazon Lex Integration and have also tested Before Method and After Method. Now you can start using the Lex Bot.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ixhello.com/ixhc/apps/intentfeature-beforeaftermethod.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
