# Login

## Playbook

In the playbook you define a step by step guide how the authentication needs to be completed.

### Playbook types

#### GOTO

Go to a specific url during authentication or start the authentication at a specific url

#### TYPE

Type in the value into a input field or type in a generated value

* Selector: HTML query selector to select the specific field
* Value: Field value
* Action: Action that must be taken on the value (generate TOTP)

#### CLICK

Click on element on the page to continue example the submit button of a form

* Selector: HTML query selector to select the element that must be clicked

#### WAIT

Wait for a specific event to be completed before continuing to the next step

* waitForSelector: Wait for a specific element to be visible on the page
* waitForNavigation: Wait until crawler has navigated to another page
* waitForTimeout: Wait for a pre set timeout

### Examples

Simple login form without field id's

{% code overflow="wrap" %}

```jsonp
{
 "login": {
    "playbook": [
      // Navigate to the login page
      {
        "type": "goto",
        "url": "https://example.com/login"
      },
      // Type in the required fields
      {
        "type": "type",
        "selector": "input[type='email']",
        "value": "developers@chathive.co",
      },
      {
        "type": "type",
        "selector": "input[type='password']",
        "value": "Your_password",
      },
      // Submit form
      {
        "type":"click",
        "selector": "input[type='submit']",
      },
      // Wait until form submit is completed
      {
        "type": "wait",
        "action": "waitForNavigation"
      }
    ]
  },
}
```

{% endcode %}

With TOTP token beining asked on a next page

{% code overflow="wrap" %}

```jsonp
{
"login": {
    "playbook": [
      // Navigate to the login page
      {
        "type": "goto",
        "url": "https://example.com/login"
      },
      // Type in the required fields
      {
        "type": "type",
        "selector": "#username",
        "value": "developers@chathive.co"
      },
      {
        "type": "type",
        "selector": "#password",
        "value": "Your_password"
      },
      {
        "type": "click",
        "selector": "#submitForm"
      },
      // Wait until form is submitted and TOTP field becomes visible
      {
        "type": "wait",
        "action": "waitForSelector",
        "selector": "#totpToken"
      },
      {
        "type": "type",
        "selector": "#totpToken",
        "action": "generateTOTP",
        "totp": {
          "secret": "TOTP_SECRET",
          "algorithm": "SHA-1"
        }
      },
      {
        "type": "click",
        "selector": "button[type=\"submit\"]"
      },
      // Wait until form submit is completed
      {
        "type": "wait",
        "action": "waitForNavigation"
      }
    ]
  }
}
```

{% endcode %}

### Best practices&#x20;

* Always specify a goto url as first step
* Use **wait** step as last to be sure login succeeded and credentials are provided


---

# 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.chathive.app/crawler/crawler-config/login.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.
