# Web Push

Empower your web application with Antsomi WebPush to deliver impactful notifications, fostering effective engagement and communication. Web push notifications offer a dynamic avenue for timely, personalized, and efficient information delivery, enhancing user interactions with your website.

To kickstart the integration of Antsomi WebPush, follow these steps to load the SDK asynchronously. This ensures optimal page load times and a seamless integration process.

### Initialization

Antsomi WebPush recommends loading `webpush.js` with the `async` flag so your page load times don't increase. To use it, place the following code *before* calling any other Antsomi WebPush functions.

{% tabs %}
{% tab title="HTML" %}

```html
<!-- CDP Web Insight script -->
<script src="https://st-a.cdp.asia/webpush.js" async></script>
<script>
  window.AntsomiPush = window.AntsomiPush || [];

  AntsomiPush.push(function() {
    AntsomiPush.init({
      portalId: <PORTAL_ID>, // Replace it with your Portal ID
    });
  });
</script>
```

{% endtab %}
{% endtabs %}

### Adding Service Worker

#### What are Service Workers?

Web Push Notifications, excluding Safari, require Service Worker files on your domain for subscription and notification reception. These files are downloaded upon accepting web notifications.

#### Integrating Antsomi WebPush Service Worker Files

1. **Download `sw.js` Files:** [link](https://drive.google.com/file/d/1InyiG3YeSBqysZcI9JxDB2YY3APfHqze/view?usp=sharing)
2. **Add Service Workers to the Website:** The `sw.js` file must be publicly accessible and can be placed at the top-level root of your site, e.g., <https://example.com/sw.js>.

<figure><img src="https://1976329911-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi16t4WMYZYowEFalUZLL%2Fuploads%2FZgnGJ2xBiYKyLks8ZFfl%2Fimage.png?alt=media&#x26;token=ab77161a-3822-4083-9d48-5c784c4b4e02" alt=""><figcaption><p>Example of the URL: https://example.com/sw.js</p></figcaption></figure>


---

# 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.antsomi.com/developers-guide/website/web-push.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.
