# Subscribe for Notifications

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

Notifications make it easy for your controller to always know the current state of the titles that it manages.

To implement, use the [`scheduleCommand`](/captivate-api/javascript-api-reference/using-the-servicehandler/schedulecommand-method.md) API call.

`scheduleCommand` is a general purpose API that supports a wide range of commands. In fact, even the `scheduleAction` call can be made through `scheduleCommand`.

It takes three parameters: the command name, a JavaScript object with all the parameters, and a JavaScript object with optional variable settings. Note that the last app in the tour, [JSON Command Tester](/api-examples/json-command-tester.md), provides a way to try all the commands and it documents all of the parameters for each.

```javascript
scheduler.scheduleCommand('subscribe', { input: inputName, events: 'play, data' }, {});
```

In this case, the command is “subscribe.” The parameter “input” instructs it to subscribe to all titles connected to this input, and the parameter “events” sets which behaviors to notify: “play” for playback status and “data” for changes in variables.

To receive notifications, you must also respond to [`onNotify`](/captivate-api/javascript-api-reference/using-the-servicehandler/signals.md) events from the scheduler.

```javascript
// Once subcriptions are enabled, listen for onNotify callbacks.
scheduler.onNotify.connect((notification) => {
  // Convert the payload string into a JavaScript object.
  let jsonReply = JSON.parse(notification);
  // And then use the object to inform the state...
});
```

\\


---

# 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://developers.newbluefx.com/api-examples/sample-controllers-tour/02-subscribe-for-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.
