# Nethouse connection

ChatRex uses Nethouse’s automatically updated YML upload to search for products, obtain cards, check availability and links. Access to orders, buyers and payments is not required.

## Preparation for unloading

1. In the Nethouse office, open **Shop>Marketplaces**.
2. Enable catalog transfer and save settings.
3. Copy the link of the automatically updated YML upload. It usually ends with `pricelist.xml`; use the address shown in your office.
4. Check that the storefront and upload are available over HTTPS and the upload contains the right goods.

Do not upload a single file to ChatRex: you need a valid link to update the directory.

## Connecting to ChatRex

1. Open **Integrations → Connect integration**, find **Nethouse** and press **Connect**.
2. On the **Connection installation** tab, fill in **Public site address** and **YML directory link**.
3. Press **Connect the directory** and wait for the status **Connected**.
4. Check the ChatRex subscription terms and add [Nethouse actions](<../../actions/integrations/nethouse.md>) to the bot.

Unloading is stored encrypted. YML up to 20 MB is allowed. The server re-syncs the directory every 30 minutes; changes do not appear instantly. In case of import error, the previous successful version is not replaced by partially loaded data. Do not use outdated data as confirmation of the current balance.

## Availability and quantity

The value of “available” in YML does not mean that the quantity in stock is known. This integration conveys availability without an exact amount. The bot must report presence without a fictitious residue.

Price, currency, description and characteristics are taken from unloading. The completeness of this data depends on the settings of the store.

The product may not be in the unloading, even if its page opens on the site. For example, in a verified store, goods with zero balance and off-sale on order did not fall into YML. If the search does not find the item, check its presence in the upload and availability settings in Nethouse. Absence in search alone does not confirm a zero residue.

## Chat via Yandex Tag Manager

Connecting a directory and installing a chat are separate steps. To chat, you need a **OnChat** connection in ChatRex, a Yandex Metrics counter and a Yandex Tag Managera container. Check the availability of the Metrics app in Nethouse in your site tariff.

### Prepare the chat.

1. Connect **OnChat** to ChatRex and add the HTTPS storefront domain to the permitted domains in the **Settings** tab.
2. Assign an OnChat bot in the **Channels and Launch** tab and save the bot.
3. In the Nethouse connection, select chat and click **Get the widget code**. Save the address from the `src` attribute: it contains your OnChat ID.

### Connect the meter to the site.

1. In Yandex Metric, select the existing counter of this storefront or create a new one with its domain. A webvisor is not required for chat.
2. In Nethouse, open **Applications → Yandex. Metric**, insert the code of this counter and save the settings.
3. In Yandex Metric, open **Tag Manager** for this counter and create a container if it does not already exist.
4. Allow the use of custom HTML in the counter settings if the interface requests it when creating the tag.

### Add the widget.

In the container, create the **User HTML** tag. The ChatRex widget loads as a JavaScript module: use the bootloader below. Replace `YOUR_ONCHAT_ID` with the identifier from the `src` address received in ChatRex.

```html
<script>
(function () {
  if (document.getElementById("chatrex-nethouse-widget")) return;
  var script = document.createElement("script");
  script.id = "chatrex-nethouse-widget";
  script.type = "module";
  script.src = "https://app.chatrex.pro/chatrex-widget.js?integration_id=YOUR_ONCHAT_ID";
  document.head.appendChild(script);
}());
</script>
```

1. Set up the launch tag on the pages of your storefront. If the counter is used on several sites, limit the launch to the desired domain.
2. Save the tag and **publish the container version**. The saved draft does not yet run the widget on the site.
3. Open the public storefront and open the chat. Updating the published container may appear with a delay due to caching.
4. Ask a question about the product that is in YML and wait for the answer. Check the name, price and link with the storefront.

Do not install two tags with the same widget at the same time. If the chat button does not appear, check the publication of the container, the domain, the OnChat identifier and the absence of a meter lock in the browser. If the chat opens but doesn’t respond, check the bot’s purpose, activity, and existing ChatRex subscriptions.

## Shutdown

Click **Break connection** in the Nethouse connection. The directory will be inaccessible to the actions of the bot. To remove the chat from the storefront, separately disable the ChatRex tag in Yandex Tag Managere and publish the changes to the container.

A ChatRex subscription is issued within ChatRex separately from Nethouse.
