# LangGraph

## 1. Install the CLI

**npm**

    ```bash
    npm install -g swytchcode
    ```

**Windows**

    ```powershell
    irm https://cli.swytchcode.com/install.ps1 | iex
    ```

**macOS / Linux**

    ```bash
    curl -fsSL https://cli.swytchcode.com/install.sh | sh
    ```

Use `swy` as a shorter alias for `swytchcode`.

## 2. Install the packages

**JavaScript**

    ```bash
    npm install @swytchcode/runtime @langchain/core langgraph dotenv
    ```

**Python**

    ```bash
    pip install swytchcode-runtime langgraph python-dotenv
    ```

## 3. Initialize Swytchcode and fetch a toolkit

```bash
swy init
swy get github
```

`swy init` creates `.swytchcode/` and `tooling.json` for the project. `swy get github` downloads the GitHub integration bundle - the schemas that `tools.get` reads from in the next step.

## 4. Load the tools

**JavaScript**

    ```ts
    import 'dotenv/config';
    import { Swytchcode } from '@swytchcode/runtime';
    import { LangGraphProvider } from '@swytchcode/runtime/providers/langgraph';

    const swx = new Swytchcode(new LangGraphProvider());
    const tools = await swx.tools.get({ toolkits: ['github'] });
    ```

**Python**

    ```python
    import os
    from dotenv import load_dotenv
    from swytchcode_runtime import Swytchcode

    load_dotenv()

    swx = Swytchcode()
    tools = swx.tools.get(toolkits=["github"])

    print(f"Loaded {len(tools)} tools")
    ```

## 5. Pass them into LangGraph

**JavaScript**

    ```ts
    // Build your graph with the returned tools and let the agent invoke them.
    console.log('LangGraph tools ready:', tools.length);
    ```

**Python**

    ```python
    result = swx.tools.execute("github.pull_requests.list", {
        "params": {"state": "open"},
        "Authorization": f"Bearer {os.getenv('GITHUB_TOKEN')}",
    })

    print(result)
    ```

## 6. Run the file

Save the example as `main.js` or `main.py`, then run the matching command:

**JavaScript**

    ```bash
    node main.js
    ```

**Python**

    ```bash
    python main.py
    ```

This keeps tool execution inside Swytchcode while the workflow graph stays focused on orchestration.

## Example projects

- [Weekly Reporting](https://github.com/swytchcodehq/swytchcode-examples/tree/main/weekly-reporting-langgraph) - Agent writes a weekly activity report to Notion and emails it via Resend — no human in the loop.
- [Lead Qualification](https://github.com/swytchcodehq/swytchcode-examples/tree/main/lead-qualification-langgraph) - Qualifies inbound leads and creates contacts and deals in HubSpot automatically.
- [Fintech Compliance](https://github.com/swytchcodehq/swytchcode-examples/tree/main/fintech-compliance-multiuser-langgraph) - Covers bank account linking (Plaid), KYC (Persona), payments (Dwolla), and policy enforcement in one flow.
- [Customer Onboarding](https://github.com/swytchcodehq/swytchcode-examples/tree/main/customer-onboarding-langgraph) - Signup flow that creates a HubSpot contact, a Stripe customer, and sends a Resend welcome email.
