Skip to main content
This guide walks you through installing all the required tools and dependencies to build OpenChat bots using the Motoko SDK.

System Requirements

Before you begin, ensure your system meets these requirements:
  • Operating System: macOS, Linux, or WSL2 on Windows
  • Node.js: Version 16 or higher
  • Memory: At least 4GB RAM available
  • Disk Space: 2GB free space for tools and dependencies

Step 1: Install Node.js

The SDK requires Node.js version 16 or higher for package management and development tools.
Using Homebrew:
brew install node
Or download from nodejs.org
Verify the installation:
node --version  # Should be v16.0.0 or higher
npm --version   # Should be 8.0.0 or higher

Step 2: Install dfx (Internet Computer SDK)

dfx is the command-line tool for developing on the Internet Computer. The SDK requires dfx version 0.14 or higher.
1

Install dfx

Run the dfx installer:
sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
This installs dfx to ~/.local/share/dfx/bin/dfx
2

Add dfx to your PATH

The installer typically adds dfx to your PATH automatically. If not, add this to your ~/.bashrc or ~/.zshrc:
export PATH="$HOME/.local/share/dfx/bin:$PATH"
Then reload your shell configuration:
source ~/.bashrc  # or ~/.zshrc
3

Verify installation

dfx --version  # Should be 0.14.0 or higher
For more installation options and troubleshooting, see the official dfx installation guide.

Step 3: Clone the Repository

Clone the OpenChat Bot SDK repository:
git clone https://github.com/AleDema/OC-Sample-Bot.git
cd OC-Sample-Bot

Step 4: Install Dependencies

The SDK uses both npm and Mops (Motoko Package Manager) for dependencies.
1

Install npm packages

Install Node.js development dependencies:
npm install
This installs:
  • ic-mops: Motoko package manager
  • mo-dev: Live reload development server
  • npm-run-all: Script runner
  • prettier and prettier-plugin-motoko: Code formatting
2

Install Mops packages

Mops packages are automatically installed via the postinstall script, but you can also run manually:
npm run sources  # or: mops install
This installs Motoko dependencies from mops.toml:
  • base: Motoko base library
  • map: Efficient map data structure
  • time-consts: Time constants
  • prng: Pseudo-random number generator
  • datetime: Date and time utilities

Step 5: Set Up Local Development Environment

Configure your local Internet Computer replica for development:
1

Start the local replica

Start a local Internet Computer replica in the background:
dfx start --clean --background
The --clean flag starts with a fresh state, and --background runs it in the background.
2

Create and deploy canisters

Create canisters and deploy them to your local replica:
npm run setup
This command:
  1. Installs all dependencies
  2. Creates canister IDs
  3. Generates type bindings
  4. Deploys canisters to the local replica
3

Start the development server

Start the live reload development server:
npm start
This runs mo-dev, which automatically:
  • Watches for file changes
  • Recompiles and redeploys on save
  • Generates updated type bindings
Keep npm start running in a terminal while you develop. It will automatically rebuild and redeploy your code when you save changes.

Step 6: Verify Installation

Verify everything is working correctly:
cat canister_ids.json
Expected output for getBotStatus:
(variant { NotInitialized })

Project Structure

After installation, your project should look like this:
OC-Sample-Bot/
├── backend/              # Motoko source code
│   ├── Bot/             # Bot service implementation
│   ├── OC/              # OpenChat API integration
│   ├── Governance/      # NNS governance integration
│   ├── Proposal/        # Proposal processing
│   ├── TallyBot/        # TallyBot implementation
│   ├── ProposalBot/     # ProposalBot implementation
│   └── Log/             # Logging infrastructure
├── node_modules/        # npm dependencies
├── .dfx/                # dfx cache and build artifacts
├── dfx.json             # Canister configuration
├── mops.toml            # Motoko dependencies
├── package.json         # npm configuration
└── canister_ids.json    # Generated canister IDs

Configuration Files

dfx.json

The dfx.json file defines your canisters:
{
  "canisters": {
    "OCBot": {
      "type": "motoko",
      "main": "backend/TallyBot/TallyBotMain.mo"
    },
    "CG_Bot": {
      "type": "motoko",
      "main": "backend/ProposalBotMain.mo"
    }
  },
  "defaults": {
    "build": {
      "packtool": "npm run --silent sources"
    }
  },
  "output_env_file": ".env",
  "version": 2,
  "dfx": "0.24.1"
}

mops.toml

The mops.toml file defines Motoko dependencies:
[dependencies]
base = "0.11.1"
map = "9.0.1"
time-consts = "1.0.1"
prng = "0.0.3"
datetime = "0.1.3"

Environment Variables

After running dfx deploy, dfx generates a .env file with canister IDs:
CANISTER_ID_OCBOT=rrkah-fqaaa-aaaaa-aaaaq-cai
CANISTER_ID_CG_BOT=ryjl3-tyaaa-aaaaa-aaaba-cai
These can be used in scripts or other tools that need to interact with your canisters.

Optional: Install Candid UI

For visual inspection and testing of your canister interfaces:
dfx canister install --all --mode reinstall
Then access the Candid UI at:
http://localhost:4943/?canisterId=<CANDID_UI_CANISTER_ID>&id=<YOUR_CANISTER_ID>

Troubleshooting

Ensure dfx is in your PATH. Add to your shell configuration:
export PATH="$HOME/.local/share/dfx/bin:$PATH"
Then reload: source ~/.bashrc
Ensure you have internet connectivity and try:
rm -rf .mops
mops install
Stop and restart dfx:
dfx stop
dfx start --clean --background
npm run setup
dfx is already running. Either use the existing instance or stop it:
dfx stop
dfx start --clean --background

Next Steps

Quickstart

Deploy your first bot and send a message

Bot Architecture

Understand the SDK’s module structure

Bot Initialization

Learn how to register and configure your bot

API Reference

Explore the complete API documentation

Additional Resources

Build docs developers (and LLMs) love