# MS SQL Server

**What is SQL Server?**

SQL SERVER is a relational database management system (RDBMS) developed by Microsoft. SQL Server comes in different versions such as Enterprise, Standard, Express, and Developer. iX Hello support all editions.

The iX Hello platform allows for the rapid integration of SQL Server to various voice channels such as Alexa, Lex, Google Assistant, and more.

## Prerequisites

* SQL Server should support remote connection.
* iX Hello IP should be whitelisted so a connection can be established from iX Hello to the Microsoft SQL Server RDS instance.

Enabling Remote connections to the SQL server:

**Option 1: Using Transact-SQL**

1. Connect to the Database Engine.
2. From the Standard bar, click New Query.
3. Copy and paste the following example into the query window and click Execute.

```
EXEC sp_configure 'remote access', 0 ;
GO
RECONFIGURE ;
GO
```

**Option 2: Using SQL Server Management Studio**

To configure the remote access option:

1. In Object Explorer, right-click a server and select Properties.
2. Click the Connections node.
3. Under Remote server connections, select or clear the Allow remote connections to this server check box.

The screenshot below shows the settings:

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

## Configuring Microsoft SQL server with iX Hello

To configure Microsoft SQL Server in the iX Hello platform, browse to: Integration > Connect System > Add New Connection > Connect External System and select Microsoft SQL Server under Choose Connection:

&#x20;

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

&#x20;

On the configuration screen, provide the required information as shown below.

<figure><img src="/files/4kdupoHlPcliLUg8866w" alt=""><figcaption></figcaption></figure>

You should be able to get these configuration settings from the SQL Server connectivity and security settings. You may need to contact the SQL Server administrator for these values.

| Configuration         | Info                                                                                                                                       |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| Service Instance Name | You can give any name here. This name will appear as Instance Name in iX Hello platform.                                                   |
| Host                  | Hostname or IP Address of SQL Server. If you are not using the default port (1443), include the new value. E.g. sqlserverhost:*portnumber* |
| Username              | SQL Server Username                                                                                                                        |
| Password              | Database Password for the username                                                                                                         |
| Database Name         | Name of the Database that you are going to use.                                                                                            |

## Create Custom App

Once you have saved the settings, browse to: Custom Apps > Manage Apps and create a new Custom App by clicking on “Create New Custom App” button. Fill out the details as shown below:

<figure><img src="/files/ItXua2YpQmlh3EeIRlYQ" alt="" width="375"><figcaption></figcaption></figure>

## Create Data Source

Create a data source for SQL Server by navigating to Data Source tab on the same screen. Make sure to select the integration configuration set up in previous step under Integration Configuration.

<figure><img src="/files/hXqYKb3YA3CQIX5uNN99" alt="" width="375"><figcaption></figcaption></figure>

## Create Methods

Now you can now create methods for the SQL Server Instance.

As of the publication of this document, iX Hello supports the following Microsoft SQL Server (MSSQL) methods:

1. Get Databases
2. Get Tables
3. Get All Items
4. Get Item
5. Get Items
6. Post Item
7. Put Item
8. Post Item without Primary Key
9. Delete Item
10. Run Select Query

### Method: GetDatabases

Parameters: Not required

This method returns a list of all the available instances.

| Parameter             | Info                                                                                                                                                                                                                                                                                                                      |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Method Name           | GetDatabases                                                                                                                                                                                                                                                                                                              |
| Request Type          | <p>GetDatabases</p><p>This is the method that you are using</p>                                                                                                                                                                                                                                                           |
| Parameters            | See configuration table above                                                                                                                                                                                                                                                                                             |
| Result Type           | <p>List of Records</p><p>Indicates that the method can return a list rather than a single record</p>                                                                                                                                                                                                                      |
| Record Limit          | 10                                                                                                                                                                                                                                                                                                                        |
| Record JsonPath       | <p>Each method returns data in JSON format. To pick any specific information from the JSON, we need to specify the <em>Record JsonPath</em> so that the iX Hello platform will pick that data in consideration while displaying results.</p><p>Example: $.\[\*]</p><p>This selects all the records that are returned.</p> |
| Empty Result Template | <p>Sorry, no database found in the given server. How else can I help you?</p><p>Note:</p><p>Anything written in between {{ }} is represented as a JSON field and is case-sensitive.</p>                                                                                                                                   |
| Result Template       | <p>Here are the databases found {{Records}}. How else can I help you?</p><p>{{Records}} represents that the record template is going to loop around all the items in the list.</p>                                                                                                                                        |
| Record Template       | <p>{{DatabaseName}}</p><p>Note:</p><p>Anything written in between {{ }} is represented as a JSON field and is case-sensitive and derived from the result obtained from the method.</p><p>It represents a single record of the list.</p>                                                                                   |

Below is a sample response format – You should get response like this.

```json
[
  {"DatabaseName":"database1"},
  {"DatabaseName":"Instance2"},
]
```

You can test whether the method has been created correctly by clicking on Test on the action menu. The object screen shall display all the values that are being retrieved from the method while the Result tab presents how the output will be presented to the user.

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

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

### Method: GetTables

Parameters:

| Parameter    | Sample Value | Info                                                      |
| ------------ | ------------ | --------------------------------------------------------- |
| DatabaseName | Db1          | Name of the database instance selected from the dropdown. |

Method Parameters:

| Parameter             | Info                                                                                                                                                                                                                                                                                                                                                                                                     |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                       |                                                                                                                                                                                                                                                                                                                                                                                                          |
| Method Name           | GetTables                                                                                                                                                                                                                                                                                                                                                                                                |
| Request Type          | <p>GetTables</p><p>The method you are using</p>                                                                                                                                                                                                                                                                                                                                                          |
| Parameters            | See configuration table above                                                                                                                                                                                                                                                                                                                                                                            |
| Result Type           | <p>List of Records</p><p>It indicates that the method can return a list of records rather than a single record</p>                                                                                                                                                                                                                                                                                       |
| Record Limit          | 10                                                                                                                                                                                                                                                                                                                                                                                                       |
| Record JsonPath       | <p>Each method returns data in JSON format. To extract any specific information from the JSON, we need to specify the <em>Record JsonPath</em> so that the iX Hello platform will choose that data while displaying results.</p><p>Example: $.\[\*]</p><p>This selects all the records returned.</p>                                                                                                     |
| Empty Result Template | <p>No tables created for {{Input.DatabaseName}}. How else can I help you?</p><p>Note:</p><p>Anything written in between {{ }} is represented as a JSON field and is case-sensitive. {{Input.DatabaseName}} represents that it is replaced by whatever value is provided by user input. For example, if the input parameter name was providerName, the field should be set as {{Input.providerName}}.</p> |
| Result Template       | <p>Here are the tables found {{Records}}. How else can I help you?</p><p>{{Records}} represents that the record template is going to loop around all the items in the list.</p>                                                                                                                                                                                                                          |
| Record Template       | <p>{{TableName}}</p><p>Note:</p><p>Anything written in between {{ }} is represented as a JSON field and is case-sensitive and derived from the result obtained from the method.</p><p>This represents a single record from the list.</p>                                                                                                                                                                 |

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

Below is a sample response format. You should get response like this:

```json5
[
{
"TableName": "Product"
}
]
```

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

### Method: GetAllItems

Parameters:

| Parameter | Sample Value | Info                            |
| --------- | ------------ | ------------------------------- |
| TableName | Product      | SQL Server database table name. |

Method Parameters:

| Parameter             | Info                                                                                                                                                                                                                                                                                                                                                                                            |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Method Name           | GetAllItems                                                                                                                                                                                                                                                                                                                                                                                     |
| Request Type          | <p>GetAllItems</p><p>The method used.</p>                                                                                                                                                                                                                                                                                                                                                       |
| Parameters            | See configuration table above.                                                                                                                                                                                                                                                                                                                                                                  |
| Result Type           | <p>List of Records</p><p>It indicates that the method can a list of records rather than a single record.</p>                                                                                                                                                                                                                                                                                    |
| Record Limit          | 10                                                                                                                                                                                                                                                                                                                                                                                              |
| Record JsonPath       | <p>Each method returns data in JSON format. To pick any specific information from the JSON, we need to specify the <em>Record JsonPath</em> so that the iX Hello platform will pick that data when displaying results.</p><p>Example: $.\[\*]</p><p>This selects all the records returned.</p>                                                                                                  |
| Empty Result Template | <p>No tables created for {{Input.TableName}}. How else can I help you?</p><p>Note:</p><p>Anything written in between {{ }} is represented as a JSON field and is case-sensitive. {{Input.TableName}} represents that it is replaced by whatever value is provided by user input. For example, if the input parameter name was providerName, it should be entered as {{Input.providerName}}.</p> |
| Result Template       | <p>Here are the details found {{Records}}. How else can I help you?</p><p>{{Records}} represents that the record template is going to loop around all items in the list.</p>                                                                                                                                                                                                                    |
| Record Template       | <p>{{FirstName}}</p><p>Note:</p><p>Anything written in between {{ }} is represented as a JSON field and is case-sensitive and derived from the result obtained from the method. It should be the field name in the table.</p><p>It represents the single record of the list.</p>                                                                                                                |

Sample Response:

<pre class="language-json"><code class="lang-json">[
  {
    "Productid": "1",
    "Name": "Smart Watch",
    "Price": "100",
  },
  {
    "Productid": "2",
    "Price": "50",
    "Name": "Product A"
<strong>  }
</strong>]
</code></pre>

### Method: GetItem

Parameters:

| Parameter       | Sample Value | Info                                           |
| --------------- | ------------ | ---------------------------------------------- |
| TableName       | Product      | SQL Server Database Table name.                |
| PrimaryKeyName  | Productid    | Name of the primary Key for the provided table |
| PrimaryKeyValue | 1            | Value for the Partition Key                    |

Method Parameters:

| Parameter             | Info                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                       |                                                                                                                                                                                                                                                                                                                                                                                                       |
| Method Name           | GetItem                                                                                                                                                                                                                                                                                                                                                                                               |
| Request Type          | <p>GetItem</p><p>The method used</p>                                                                                                                                                                                                                                                                                                                                                                  |
| Parameters            | See configuration table above                                                                                                                                                                                                                                                                                                                                                                         |
| Result Type           | <p>Record</p><p>Indicates that the method returns a single record rather than a list of records.</p>                                                                                                                                                                                                                                                                                                  |
| Record JsonPath       | <p>Each method returns data in JSON format. To extract any specific information from the JSON, we need to specify the <em>Record JsonPath</em> so that the iX Hello platform will pick that data while displaying results.</p><p>Example: $.\[\*]</p><p>This selects all the records that is returned.</p>                                                                                            |
| Empty Result Template | <p>No data found for {{Input.TableName}}. How else can I help you?</p><p>Note:</p><p>Anything written in between {{ }} is represented as a JSON field and is case-sensitive. {{Input.TableName}} represents that it is replaced by whatever value is provided by the user in input. For example, if the input parameter name was providerName, it shall have been used as {{Input.providerName}}.</p> |
| Result Template       | <p>Here are the details found {{Name}}. How else can I help you?</p><p>{{Records}} represents that the record template is going to loop through all the items in the list.</p>                                                                                                                                                                                                                        |

Sample Response:

```json
{
  "Productid": "1",
  "Name": "Smart Watch",
  "Price": "100",
}
```

Here there is only one matching record. If there are multiple records, you will get multiple items in the JSON array.

### Method: PostItem

Parameters:

| Parameter         | Sample Value                         | Info                            |
| ----------------- | ------------------------------------ | ------------------------------- |
| TableName         | Product                              | SQL Server database table name. |
| PartitionKeyName  | Productid                            | Name of the Partition Key       |
| PartitionKeyValue | 1                                    | Value for the Partition Key     |
| ItemData          | {"Name": "Smart Watch","Price": 100} | Item data in JSON format        |

Sample Response:

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

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

```json
{
  "Productid": 1,
  "Name": "Smart Watch",
  "Price": 100
}
```

### Method: PostItemWithoutPrimaryKey

Parameters:

<table><thead><tr><th width="164">Parameter</th><th width="289">Sample Value</th><th>Info</th></tr></thead><tbody><tr><td>TableName</td><td>Product</td><td>SQL Server database table name.</td></tr><tr><td>ItemData</td><td>{ "Name": "Smart Watch",<br> "Price": 100 }</td><td>Item data in JSON format</td></tr></tbody></table>

Sample Response:

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

&#x20;

### Method: PutItem

Parameters:

<table><thead><tr><th width="183">Parameter</th><th width="274">Sample Value</th><th>Info</th></tr></thead><tbody><tr><td>TableName</td><td>Product</td><td>SQL Server database table name.</td></tr><tr><td>PartitionKeyName</td><td>Productid</td><td>Name of the Partition Key</td></tr><tr><td>PartitionKeyValue</td><td>1</td><td>Value for the Partition Key</td></tr><tr><td>ItemData</td><td>{ "Name": "Smart Watch 2",<br> "Price": 111 }</td><td>Item data in JSON format</td></tr></tbody></table>

Sample Response:

This is same as Post Item. The only difference is Put Item updates the record and Post Item inserts the record.

```json
{
  "Productid": 1,
  "Name": "Smart Watch 2",
  "Price": 111
}
```

<figure><img src="/files/9F69EU8gCh0VBvIyXzF7" alt=""><figcaption></figcaption></figure>

### Method : DeleteItem

Parameters:

| Parameter         | Sample Value | Info                            |
| ----------------- | ------------ | ------------------------------- |
| TableName         | Product      | SQL Server database table name. |
| PartitionKeyName  | Productid    | Name of the Partition Key       |
| PartitionKeyValue | 1            | Value for the Partition Key     |

Response:

<figure><img src="/files/6iRCZWFdpIDsYkBvQYj7" alt=""><figcaption></figcaption></figure>

**Method: RunSelectQuery**

### Method : RunSelectQuery

Parameters:

| Parameter       | Sample Value                       | Info                          |
| --------------- | ---------------------------------- | ----------------------------- |
| SelectStatement | select ProductId,Name from Product | A valid SQL select statement. |

Sample Response:

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

<pre class="language-json"><code class="lang-json">[
  {
    "ProductId": 1,
    "Name": "Smart Watch"
  },
  {
    "ProductId": 2,
<strong>    "Name": "Product A"
</strong>  }
]
</code></pre>

## Create Intents

Create Intents corresponding to each method.

**GetTablesIntent**

Details:

Name: GetTablesIntent

IntentType: Search

Intent Action: Execute Method

Primary Method Data Source: SQL DS

Data source Method: GetTables

<figure><img src="/files/l5e4JxnLG9wQwtlVFC4T" alt="" width="375"><figcaption></figcaption></figure>

## Create Slots

Create intents corresponding to every method. For every parameter used in the method, you need to create a corresponding slot. Slot name shall match the parameter name.

| Details:                                     |
| -------------------------------------------- |
| Name: DatabaseName                           |
| Slot Order: 0                                |
| Reprompt Message: “what’s the database name” |
| Type: Text                                   |
| Custom App: SQL Demo                         |
| Intent: GetTablesIntent                      |

<figure><img src="/files/8BGTryjyxAJnWnRChmQ0" alt="" width="375"><figcaption></figcaption></figure>

## Create Utterances

To invoke the intent, you need to create utterances. Utterances are short text that act as a trigger to invoke the intent.

Utterance for GetTables

| Details:                |
| ----------------------- |
| Value: get all tables   |
| Custom App: SQL Demo    |
| Intent: GetTablesIntent |

<figure><img src="/files/9NHbrMXjCOKjJuPOOxpp" alt="" width="375"><figcaption></figcaption></figure>

## Create Inputs

Create Inputs corresponding to the Intent

| Details:                       |
| ------------------------------ |
| Name: GetTablesInput           |
| Custom App: SQL Demo           |
| Custom Intent: GetTablesIntent |
| DataSource: SQL DS             |
| Data Source Method: GetTables  |

## Create Publish and Publish to Channel

On the Publish tab, click on Add App publishing and fill following details:

| External App Name: SQL Demo                |
| ------------------------------------------ |
| App Type: Survey                           |
| Channel: Alexa                             |
| Skill Invocation: database demo            |
| Messages: Fill with your suitable prompts. |

After creating the publish, you will be able to publish the app to the channel selected and test the app as well.

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

On the Developer Console, once the skill builds successfully, you can invoke the intents and test the app. Here is a sample one,

<figure><img src="/files/7HUIaska9OhRHqhxKUPf" alt="" width="375"><figcaption></figcaption></figure>

You can refer to [this](https://docs.ixhello.com/apps/intentfeature-beforeaftermethod) document for a more descriptive step by step guide for app creation and publishing in iX Hello.

&#x20;


---

# 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/connections/ms-sql-server.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.
