# Push Notifications

## Video

Watch this video where I walk you through the process of setting up [IFTTT](https://ifttt.com/) and integrate it with our JavaScript code:

{% embed url="<https://youtu.be/we0f7To3Aw8>" %}

## Enable webhooks service

Type "webhook" into the search field in the upper-left corner and hit enter. In the results, click on the services tab and click on the box with the label "Webhooks".

In the opening page, you should a "settings" symbol in the upper-right corner. Click this symbol to activate or deactivate your webhook-URL. Copy the URL into your browser to open the documentation page.

![](/files/-MVa0_hdZ8B5ekamuM7R)

## Create a new applet

Navigate to the [page where you can create a new applet](https://ifttt.com/create) within IFTTT. You should see the following image:

![IFTTT applets are based on a trigger and an action.](/files/-MVa0J4YwHkVIImr0ETK)

## Trigger the webhook from our app

You can copy the following function to call your IFTTT webhook from JavaScript. The function uses the `fetch()` function to make an HTTP POST request to the URL specified in the IFTTT documentation. The function expects you to pass your personal key and the event name that should be sent. Additionally, you can pass 3 possible parameter values to provide more information.

```javascript
function sendIFTTTPushNotification(
  eventName,
  key,
  value1 = null,
  value2 = null,
  value3 = null
) {
  var url =
    "https://maker.ifttt.com/trigger/" +
    eventName +
    "/with/key/" +
    key +
    "?value1=" +
    value1 +
    "&value2=" +
    value2 +
    "&value3=" +
    value3;

  fetch(url, {
    method: "post",
    mode: "no-cors",
    headers: {
      Accept: "application/json",
      "Content-Type": "application/json"
    }
  }).then(response => {
    console.log(
      "IFTTT webhook called successfully. See if there were errors before."
    );
    return true;
  });
}
```

## Links

{% embed url="<https://ifttt.com/>" %}


---

# 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://iot.datalit.de/4-cloud-and-apis/push-notifications.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.
