> For the complete documentation index, see [llms.txt](https://developers.newbluefx.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.newbluefx.com/api-examples/sample-controllers-tour/02-subscribe-for-notifications.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://developers.newbluefx.com/api-examples/sample-controllers-tour/02-subscribe-for-notifications.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
