- A frontend that writes registration data to a smart contract
- A small optional backend helper to read records when needed
- A Kwala workflow that listens for the on-chain
RecordSavedevent and sends instant Telegram confirmations
Objective
Create an onboarding flow where:- TRIGGER: Kwala listens for
RecordSaved(address,string,string,string,uint256)emitted by theSaveDatasmart contract when a user registers via the frontend. - ACTION: Kwala posts a personalized Telegram welcome message to the registered chat ID.
Prerequisites
Before you begin, ensure you have:- MetaMask (or compatible wallet) connected to the target RPC. This guide uses the Polygon Amoy testnet.
- Telegram bot token and chat IDs (create via
@BotFather) - Kwala Dashboard access to create and deploy workflows: https://kwala.network/dashboard
- Familiarity with Solidity and frontend tooling such as ethers.js, BrowserProvider, simple HTML/JS, or React
Step 1: Smart contract (SaveData.sol)
Deploy the contract below using Remix or your preferred flow. Kwala uses the event ABI to listen forRecordSaved.
SaveData.sol
Save the deployed contract address and ABI — Kwala uses the event ABI to detect
RecordSaved.Step 2: Frontend (simple onboarding UI)
A lightweight HTML and ethers frontend collects name + Telegram chat ID and callssaveRecord(...). Open this page in a browser with MetaMask installed.
index.html
- Open the page in a browser with MetaMask
- Click Connect MetaMask and sign the request
- Fill Name and Telegram Chat ID (wallet optional)
- Click Sign Up — MetaMask will prompt and the frontend calls
saveRecord() - Once mined,
RecordSavedis emitted
Telegram helper bot (get chat ID)
You can provide atgBotBtn that opens a bot which replies with the chat ID. Here’s an example bot (Node.js) that replies with the user’s chat ID when they click the /start deep link. Useful for users to capture their chat ID from the browser.
telegram-bot.js
Optional step 3: Small backend helper
This optional Node/Express helper demonstrates reading stored records on-chain and sending Telegram messages in bulk. Kwala already handles immediate notifications via events, but you may want a backend for bulk messaging, admin flows, or periodic summaries.index.js
Step 4: Kwala workflow (event → Telegram)
Create a Kwala workflow that listens forRecordSaved and posts a Telegram message. This is the core serverless glue — Kwala runs it for you.
Kwala dashboard steps
- Open: https://kwala.network/dashboard → Create New Workflow
- Name:
New_User_Onboardingworkflow(or any name you prefer) - Trigger:
- Execute After:
immediate - Repeat Every:
event - Recurring Source Contract:
0x3e2f859DA20e1e74A5696Bf3246606218c246C9F - Recurring Chain ID:
80002(Polygon Amoy) - Recurring Event Name:
RecordSaved(address,string,string,string,uint256) - Recurring Source Contract ABI: paste the event ABI (Kwala can fetch/accept the ABI)
- Action Status Notification POST URL:
- Execute After:
- Action:
- Action Name:
Telegram_notificatier - Type:
POST API CALL - API Endpoint:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/sendMessage - API Payload:
- Retries Until Success:
5 - Execution Mode:
parallel(orsequential— choose based on your need)
- Action Name:
- Save and deploy. Kwala will return the workflow address and status.
YAML configuration
workflow.yaml
Deploy and test
- Deploy
SaveDataor use the provided address:0x3e2f859DA20e1e74A5696Bf3246606218c246C9F - Serve the frontend and connect MetaMask. Fill name and Telegram chat ID and select Sign Up
- Once
saveRecordis mined, the contract emitsRecordSaved - Kwala detects the event and posts to the configured Telegram chat ID
- Optionally use the backend
/sendMessagesendpoint to read stored records and send messages in bulk
Monitor and debug
Kwala Dashboard Logs
View events processed, API calls, payloads, and retry counts in the Kwala Dashboard → Workflow Logs
Contract Explorer
Verify
RecordSaved events and transaction receipts on Amoy PolygonscanConclusion
You now have a full onboarding pattern that is:- Secure and auditable: Records are stored on-chain
- Real-time and user-friendly: Kwala sends instant Telegram confirmations after the
RecordSavedevent - Low-operational overhead: No polling servers required for event to notification glue
