> For the complete documentation index, see [llms.txt](https://mind-expression-docs.gitbook.io/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mind-expression-docs.gitbook.io/home/how-to-guides/build-info-search-subjects/case-2.-payment-history.md).

# Case 2. Payment History

### Before you begin

* This tutorial requires a webhook setup. Add a test webhook URL <http://mock-webhook.mind.ai> to your webhook settings.
* This tutorial requires an entity type. Add a regex entity type "MSISDN" in Knowledge.

#### **MSISDN**

**Regex Pattern Block 1**

**`REGEX PATTERN`**` `` ``[nN]?[fF] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] `\
`` **`DESCRIPTION`**` `` 9 digits: 1st digit can be n or N, 2nd digit can be f or F\`

**Regex Pattern Block 2**

**`REGEX PATTERN`**` `` ``[1,2,3,6,8,9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] `\
`` **`DESCRIPTION`**` `` 7 digits: 1st digit can be 1,2,3,6,8,9\`

**Regex Pattern Block 3**

**`REGEX PATTERN`**`[1,2,3,6,8,9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9]`\
\`\`**`DESCRIPTION`**`8 digits: 1st digit can be 1,2,3,6,8,9`

**Regex Pattern Block 4**

**`REGEX PATTERN`**` `` ``[0,1,2,6,8,9]-?[0-9]-?[0-9]-?[0-9]-?[0-9]-?[0-9]-?[0-9]-?[0-9]-?[0-9](-?[0-9A-Za-z])? `\
`` **`DESCRIPTION`**` `` 10 digits with " - " in between of each digit\`

**Regex Pattern Block 5**

**`REGEX PATTERN`**` `` ``[0,1,2,6,8,9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9]( ?[0-9A-Za-z])? `\
`` **`DESCRIPTION`**` `` 10 digits: 1st digit can be 0,1,2,6,8,9 and last digit can be 0-9, A-Z, a-z)\`

### Add a Subject

1. Click **Add Subject** on the Scope details page.
2. Select the `Info Search` tab.
3. Enter a Subject name.
4. Enter Query Statement which is the expected customer query as "I’d like to check my payment history."
5. Click **Recognize Statement** to get the Recognition Result. The **Recommended Statement** is the statement which is semantically related to more ontologies and can generally capture more statement structures with the same intent. To use the recommended statement, just tick the checkbox saying **Use Recommended Statement**.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2F50jTAJ32myocPMFzJ0sD%2Fimage.png?alt=media&amp;token=bb28b8c8-7ed4-45ea-ac2b-312df69710cf" alt=""><figcaption></figcaption></figure>

6\. **Additional Query Statement to Recognize** may also be added but not required. This is used in case of multiple intents being expected to trigger this subject.

7\. Click **Add**.

### Build the Subject

1. Click **Add Component** in the Components panel.
2. Click **Selection Class**.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2FKe9WgfT2576VWaIpZTqk%2Fimage.png?alt=media&amp;token=037b6091-14a7-4a13-9187-545aec77068d" alt=""><figcaption></figcaption></figure>

3\. Enter a Selection Class name as "Product Quantity" and Selection names as "One", "Multiple".

4\. Click **Add**.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2FfNEm1jBTG8FDSlEM4vtb%2Fimage.png?alt=media&amp;token=764cb741-2059-4ccc-8680-709c92fb68ce" alt=""><figcaption></figcaption></figure>

5\. In the Component Settings panel, enter a Selection Term for the `One` Selection as "single", then tick off the Query Statement.

6\. Click **Save**.

7\. Go to the other Selection `Multiple`.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2FfPfGVVWkoZtdWWfV94Xt%2Fimage.png?alt=media&amp;token=8adbc511-68a9-45b4-81d6-14f59a647157" alt=""><figcaption></figcaption></figure>

8\. In the Component Settings panel, enter a Selection Term for the `Multiple` Selection as "multiple", then tick off the Query Statement. Entities can also be used as a selection term, depending on which is necessary.

9\. Click **Save**.

10\. Click **Add Action** in the Conversational panel.

11\. Under Check for Selection Class, click **Check**.

12\. Select the `Webhook` tab.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2FbDqefKDROPcPAdKKdMbv%2Fimage.png?alt=media&amp;token=5272c51a-070c-4dce-a226-ba81d50de929" alt=""><figcaption></figcaption></figure>

13\. Choose a webhook URL `http://mock-webhook.mind.ai` to use from the dropdown and enter URL Parameter (domain path and/or query string) as `tutorial/mobile-phone-list?code=200&out=m`. It will return a "multiple" Selection Term for the Selection Class.

**Webhook URL (Method: GET)**

**BASE URL** `http://mock-webhook.mind.ai`

**URL PARAMETER** `tutorial/mobile-phone-list?code=200&out=m`

**Response Body**

```
{
 "mobile-phone-number-count": "multiple",
 "mobile-phone-numbers": [
 {
   "name": "Your 5G Data",
   "mobile-id": "101002000"
  },
  {
   "name": "Your 5G Video",
   "mobile-id": "201012001"
  },
  {
   "name": "Your 4G+ Voice",
   "mobile-id": "301022002"
  }
 ]
}
```

14\. Select the `GET` request method.

15\. Select an error message display method as `Template` and select an action as `Terminate` to take in case of HTTP 400. If `Passthrough` is selected, the webhook response will be displayed without modification.

16\. Enter an error message that will be displayed to the customer.

```
Sorry, I am terminating the session.
```

17\. Enter the Term Matching JSONPath.

**`JSONPATH`**`$.mobile-phone-number-count`

18\. Click **Save**.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2F4OqNAHoMTFR08Q8PGqyC%2Fimage.png?alt=media&amp;token=ee6ee597-c102-4eee-94a3-503417e73a9f" alt=""><figcaption></figcaption></figure>

19\. Click **Add Child Component** under the `Multiple` Selection in the Components panel.

20\. Click **Parameter Bundle**.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2Fu1YAN5LGEDt3vvDzYJMq%2Fimage.png?alt=media&amp;token=9d281e39-cdd1-4b9f-bced-b365184baa5e" alt=""><figcaption></figcaption></figure>

21\. In the popup, enter a Parameter Bundle name as "Show Product List" and Parameter names as "Mobile ID", "Month". Set them as required.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2FIlFUreY2KT3HzxIWRLp0%2Fimage.png?alt=media&amp;token=868b8608-0251-44b9-a2ec-6b14bb1e713d" alt=""><figcaption></figcaption></figure>

22\. Click **Add**.

23\. To set up the Mobile ID Parameter, select the **Compound Value** tab in the Component Settings panel.

24\. Enter the local binding key as "mobile\_id".

25\. Click **Set up Entity Type**.

26\. In the popup, click the System (Extensible) tab.

27\. Select the MSISDN entity type.

28\. Click **Submit**.

29\. Enter Designator.Key Path.

**KEYPATH** `$.mobile-phone-numbers.mobile-id`

30\. Click **Save**.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2Fxfb1n5PGxvRLiyDuEIYB%2Fimage.png?alt=media&amp;token=8cebc2fc-9787-4ebd-b122-85c97b827c67" alt=""><figcaption></figcaption></figure>

31\. Click **Add Action** in the Conversation panel.

32\. Under Check for Parameter, click **Check**.

33\. Select the `Combined` tab.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2FpG3AGs9TyiD1aJuAgwaH%2Fimage.png?alt=media&amp;token=e56a3027-9cd4-4369-9045-cdbdbda8c61b" alt=""><figcaption></figcaption></figure>

34\. Choose a webhook URL `http://mock-webhook.mind.ai` to use from the dropdown and enter URL Parameter (domain path and/or query string) as `tutorial/mobile-phone-list?code=200&out=m.`

**Webhook URL (Method: GET)**

**BASE URL** `http://mock-webhook.mind.ai`

**URL PARAMETER** `tutorial/mobile-phone-list?code=200&out=m`

***

**Response Body**

```
{
 "mobile-phone-number-count": "multiple",
 "mobile-phone-numbers": [
 {
   "name": "Your 5G Data",
   "mobile-id": "101002000"
 },
  {
   "name": "Your 5G Video",
   "mobile-id": "201012001"
  },
  {
   "name": "Your 4G+ Voice",
   "mobile-id": "301022002"
  }
 ]
}
```

35\. Select the `GET` request method.

36\. Select an error message display method as `Template` and select an action as `Try again` to take in case of HTTP 400. If `Passthrough` is selected, the webhook response will be displayed without modification.

37\. Enter an error message that will be displayed to the customer.

```
Please try again.
```

38\. Under Keys to Reset, enter "mobile\_id".

39\. Enter Key and JSONPath pairings for Result Mapping.

**Result Mapping Pair 1**

**KEY**`mobile_phone_number_count`

**JSONPATH**`$.mobile-phone-number-count`

**Result Mapping Pair 2**

**KEY** `mobile_phone_numbers`

**JSONPATH** `$.mobile-phone-numbers`

40\. Enter the prompt.

```
Which product would you like to see?
{{#mobile_phone_numbers}}
 {{mobile-id}}: ({{name}})
{{/mobile_phone_numbers}}
```

41\. Click **Save**.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2FPMQZ7oCb9eOqJloff8VK%2Fimage.png?alt=media&amp;token=15003711-9757-4411-bcab-5b268e619dca" alt=""><figcaption></figcaption></figure>

42\. Select the "Month" Parameter in the Components panel.

43\. In the Component Settings panel, stay with the `Single Value` tab.

44\. Enter the local binding key as "month".

45\. Click **Set up Entity Type**.

46\. In the popup, select the `System` tab.

47\. Select `Any Entity`.

48\. Click **Submit**.

49\. Click **Save**.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2FC3aW8sXPPx2zymDyqOfw%2Fimage.png?alt=media&amp;token=e3d65f5f-8788-48c9-ad32-1ec502e895ac" alt=""><figcaption></figcaption></figure>

50\. Click **Add Action** in the Conversation panel.

51\. Under Check for Parameter, click **Check**.

52\. In the Action Settings panel, stay in the `Customer` tab.

53\. Enter the prompt as "For which month?"

54\. Click **Save**.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2F7Z5mpWeJAjtnnPoeUd9t%2Fimage.png?alt=media&amp;token=74889e90-cae1-4e0b-bb31-a733f77959c8" alt=""><figcaption></figcaption></figure>

55\. Click **Show response** under Completion of Parameter Bundle on the bottom of the Conversation panel.

56\. Select the `Webhook` tab.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2FfOOQKiQSbw3YPK92K7Gv%2Fimage.png?alt=media&amp;token=1f6808dc-9f21-4d1d-b42b-e5afbfb15017" alt=""><figcaption></figcaption></figure>

57\. Choose a webhook URL `http://mock-webhook.mind.ai` to use from the dropdown and enter URL Parameter (domain path and/or query string) as `tutorial/payment-history?code=200`

**Webhook URL (Method: POST)**

**BASE URL** `http://mock-webhook.mind.ai`\
\`\`**URL PARAMETER** `tutorial/payment-history?code=200`

**Response Body**

```
{
"payment-history": "Your payment for December was made on January 5th, for 35 USD"
}
```

58\. \*\*\*\* Select the request method as `POST`. For the `POST` request, you can enter the Request Body if needed. Enter the Request Body.\\

**Request Body (Accepted month format: January to December)**

```
{
 "month": "{{month}}",
 "mobile-id": "{{mobile_id}}"
}
```

59\. Select an error message display method as `Template` and select an action as `Terminate` to take in case of HTTP 400. If `Passthrough` is selected, the webhook response will be displayed without modification.

60\. Enter an error message that will be displayed to the customer.

```
Sorry, I am terminating the session.
```

61\. Keep the Mapping toggle on.

62\. Enter Key and JSONPath pairings for Result Mapping.\
\
**KEY** `payment_history`\
\`\`**JSONPATH** `$.payment-history`

63\. Enter the template to show to the customer as a response.

```
{{payment_history}}
```

64\. Click **Save**.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2FXcP1osFRm82mMtgb6zF1%2Fimage.png?alt=media&amp;token=69f6e52b-39c7-4a5b-bd60-a44ba0e269c2" alt=""><figcaption></figcaption></figure>

65\. Click **Publish** to publish the Subject.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2FnaYpQLv9s6z5cG6LBd41%2Fimage.png?alt=media&amp;token=c7e2c47e-8725-4c53-a5c1-12763ac29ac5" alt=""><figcaption></figcaption></figure>

66\. To test the subject, click on the sandbox button on the right side of the screen and enter the query statement configured, in this case, `I'd like to check the payment history`.

<figure><img src="https://2637928320-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRqPwZJVepiA6JYXHnaO%2Fuploads%2FTfXSFlzeN11cfNHvlIC8%2Fimage.png?alt=media&amp;token=e021a5e7-1b85-4258-9d58-0e8aa260fa0a" alt=""><figcaption></figcaption></figure>
