# Push Notification

OneRoute Embed also supports push notifications and requires some dependencies from your Web App.

#### How to Install <a href="#how-to-install" id="how-to-install"></a>

* Create a `firebase-messaging-sw.js` file in your public folder (make sure to use the exact filename).
* Copy and paste the code below in the file created:

```
/* eslint-disable no-restricted-globals */
/* eslint-disable no-undef */

importScripts(
  "https://www.gstatic.com/firebasejs/9.0.0/firebase-app-compat.js"
);
importScripts(
  "https://www.gstatic.com/firebasejs/9.0.0/firebase-messaging-compat.js"
);

const firebaseConfig = {
  apiKey: "<-- Check dashboard -->",
  authDomain: "<-- Check dashboard -->",
  projectId: "<-- Check dashboard -->",
  storageBucket: "<-- Check dashboard -->",
  messagingSenderId: "<-- Check dashboard -->",
  appId: "<-- Check dashboard -->",
};

firebase.initializeApp(firebaseConfig);

// Retrieve firebase messaging
const messaging = firebase.messaging();

messaging.onBackgroundMessage(function (payload) {
  const message = JSON.parse(payload.data.message);
  console.log("NBMA");

  const notificationTitle = `New message from ${message.sender.name}`;
  const notificationOptions = {
    body: message.content,
    icon: "/favicon.ico", // Your WebApp's favicon.
  };

  self.registration.showNotification(notificationTitle, notificationOptions);
  self.addEventListener("notificationclick", function (event) {
    event.notification.close();
  });
});

```

You can find the values for the `firebaseConfig` keys on your *OneRoute Dashboard* > *Settings* > [*Account Settings*](https://app.oneroute.io/settings/account-settings) > *Notifications*.

* Redeploy your WebApp, and you should start getting push notifications.


---

# 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.oneroute.io/embed/push-notification.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.
