> For the complete documentation index, see [llms.txt](https://docs.userlane.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.userlane.com/developers/userlane-commands/start-a-guide-with-javascript.md). Agents can also search and read this documentation through its [MCP server](https://docs.userlane.com/~gitbook/mcp).

# Start a Guide with a JavaScript command

Start a Guide from a custom trigger with the `start` or `startOnce` command.

## About the start command

The `start` command launches a Guide from a custom trigger in the application, for example a button. This lets the Guide fit the application's own user experience.

{% hint style="warning" %}
The command plays the Guide directly. It does not take display rules or audience targeting into account.
{% endhint %}

Look up the Guide ID in the Userlane Portal, then insert it into one of the commands below.

## Start a Guide

```js
// replace 12345 with the Guide ID
Userlane('start', '12345');
```

When the Guide starts, the `onStart` event fires. See [Hooking into event callbacks](https://docs.userlane.com/developers/userlane-commands/event-callbacks.md).

The command does nothing while the Editor is open, or while Userlane is disabled for the application.

## Start a Guide only once per user

```js
// replace 12345 with the Guide ID
Userlane('startOnce', '12345');
```

This works only where a specific user ID is passed via the snippet. If that user ID changes, the Guide appears again.

The Guide plays only for a user who has never started it. Once a user has started the Guide, `startOnce` does not play it again, even if the user left it part way through.

`startOnce` also accepts a step index as the third argument, in the same way as `start`. See [Start a Guide at a specific step](#start-a-guide-at-a-specific-step).

`startOnce` does nothing while another Guide is playing or paused. To start the Guide anyway, pass `{ overrideRunningTutorial: true }` as the third argument. With this option the Guide starts at its first step, so it cannot be combined with a step index.

```js
// replace 12345 with the Guide ID
Userlane('startOnce', '12345', { overrideRunningTutorial: true });
```

## Start a Guide at a specific step

{% hint style="warning" %}
The step index starts at 0. That is different from the step number shown in the Editor and the Portal, which starts at 1. To start a Guide at step 11, pass the index 10.
{% endhint %}

```js
// replace 12345 with the Guide ID
// replace 4 with the index of the step
Userlane('start', '12345', 4);
```

The step index applies only once Userlane has initialized. If the command runs earlier, for example before the `init` command, the Guide starts at its first step once Userlane is ready.

{% hint style="info" %}
**Good to know**

While signed in to the Userlane Portal, the `start` command works even on a Guide set to private, which makes it a convenient way to test a trigger. End users do not see a Guide that is set to private.
{% endhint %}

## While a Guide is paused

While a user has a Guide paused, `start` and `startOnce` do not start another Guide, and the paused Guide stays paused. The browser console logs which Guide was not started. Once the user resumes or exits the paused Guide, the commands work as described above.

A link that shares a Guide does not start it either. The page opens with the paused Guide instead, and the browser console logs which Guide was not started. After the user resumes or exits the paused Guide, opening the link again starts the shared Guide.

## Relevant articles

* [Hooking into event callbacks](https://docs.userlane.com/developers/userlane-commands/event-callbacks.md)
* [Quick reference of commands](https://docs.userlane.com/developers/userlane-commands/quick-reference-of-commands.md)
* [Implement a command to open the Assistant](https://docs.userlane.com/developers/userlane-commands/open-the-assistant.md)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.userlane.com/developers/userlane-commands/start-a-guide-with-javascript.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
