How 0xoucan/nilaiagent works
Main Components
• Chatbot Engine & Interface:
• Central chatbot logic (src/chatbot.ts) and the Telegram interface integration (src/telegram-interface.ts). These components serve as the front door for user interactions.
• Action Providers:
• Different action providers by their functionality:
• NIL Account Actions (src/action-providers/nil-account): Manages balance checks and smart account operations.
• NIL Contract Actions (src/action-providers/nil-contract): Deals with deploying and interacting with various smart contract types.
• NIL Supply Chain Actions (src/action-providers/nil-supply-chain): Specifically handles the supply chain contracts, ensuring proper deployment order and interactions between Manufacturer and Retailer.
• Script Modules:
• Scripts (located in src/scripts) as components handling command execution for contract deployment and interactions. They are the bridge between the user commands (from the chatbot) and the blockchain operations.
• External Services & Configurations:
• Connections to external blockchain endpoints (NIL_RPC_ENDPOINT, NIL_FAUCET_ENDPOINT), the Cometa service for contract compilation/verification, and environment configurations.
• Optionally, note OpenAI API integration via the OPENAI_API_KEY if it plays a role in the assistant’s conversation features.
Relationships and Interactions
• User Input to Interfaces:
• How users interact with either Chat Mode or Telegram Mode, which then route commands to the Chatbot Engine.
• Chatbot Engine Workflow:
• How the chatbot engine parses commands, then dispatches requests to the appropriate Action Provider based on the operation (e.g., deploying a contract, checking balances, managing accounts, or executing supply chain orders).
• Action Providers Interaction:
• Within each module (nil-account, nil-contract, nil-supply-chain), indicate the separation of concerns such as schema validation, error handling, and specific business logic for each blockchain operation.
• Scripts and External Connections:
• Script modules that can execute commands like “deploy-counter” or “interact-supply-chain” which then use the lower-level action provider interfaces.
• External connections like NIL Blockchain (via RPC and Faucet endpoints) and Cometa for tasks like compilation and contract verification.
Architectural Patterns and Technologies
• Modular Design:
• That the project is designed in a modular fashion by separating actions into distinct providers, each encapsulating specific blockchain functionality.
• Command Pattern:
• That the chatbot processes various commands which are mapped to underlying contract deployment and interaction functionalities.
• External Integrations:
• How integration with external blockchain services, environment configurations, and possibly OpenAI APIs (given the chatbot context) play crucial roles.