Telegram Integration
For Naali (experiences.fun)
This guide will help you get the Telegram bot running in under 30 minutes.
Prerequisites
.NET 8.0 SDK installed
MongoDB connection (already configured in OASIS)
Solana wallet for token treasury
Telegram account
Step 1: Create Telegram Bot (5 minutes)
Open Telegram and search for
@BotFatherSend:
/newbotChoose a name:
OASIS Accountability BotChoose username:
oasis_accountability_bot(must end in 'bot')Copy the token you receive (looks like:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz)
Step 2: Configure OASIS (2 minutes)
Edit /NextGenSoftware.OASIS.API.ONODE.WebAPI/OASIS_DNA.json:
{
"TelegramOASIS": {
"BotToken": "PASTE_YOUR_BOT_TOKEN_HERE",
"WebhookUrl": "https://oasisweb4.one/api/telegram/webhook",
"MongoConnectionString": "mongodb+srv://OASISWEB4:Uppermall1!@oasisweb4.ifxnugb.mongodb.net/?retryWrites=true&w=majority&appName=OASISWeb4",
"TreasuryWalletAddress": "Be51B1n3m1MCtZYvH8JEX3LnZZwoREyH4rYoyhMrkxJs",
"RewardTokenMintAddress": "YOUR_SPL_TOKEN_MINT_ADDRESS",
"RewardTokenSymbol": "EXP",
"SolanaCluster": "devnet"
}
}Required Changes:
Replace
PASTE_YOUR_BOT_TOKEN_HEREwith your bot token from Step 1Replace
YOUR_SPL_TOKEN_MINT_ADDRESSwith your SPL token mint (or leave empty for now)
Step 3: Build the Project (3 minutes)
cd /Volumes/Storage/OASIS_CLEAN
# Build TelegramOASIS provider
cd NextGenSoftware.OASIS.API.Providers.TelegramOASIS
dotnet build
# Build and run the API
cd ../NextGenSoftware.OASIS.API.ONODE.WebAPI
dotnet build
dotnet runStep 4: Test the Bot (5 minutes)
Open Telegram
Search for your bot username (e.g.,
@oasis_accountability_bot)Send:
/startYou should receive a welcome message
Try:
/helpto see all commands
Test Flow:
You: /start
Bot: ๐ Welcome to OASIS! Your Telegram account has been linked...
You: /creategroup Test Accountability
Bot: โ
Group 'Test Accountability' created successfully!
You: /setgoal Complete first milestone
Bot: ๐ฏ Goal set successfully!
You: /checkin Made progress today!
Bot: โ
Check-in recorded! Karma awarded: +10
You: /mystats
Bot: ๐ Your OASIS Stats
Username: tg_yourname
Karma: 10
...Step 5: Create SPL Token (Optional - 15 minutes)
If you want to distribute actual Solana tokens:
# Install Solana CLI if not already installed
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
# Generate keypair for treasury
solana-keygen new -o ~/treasury.json
# Switch to devnet
solana config set --url https://api.devnet.solana.com
# Get devnet SOL for testing
solana airdrop 2
# Create token
spl-token create-token --decimals 9
# Copy the token address and update OASIS_DNA.json
# Example output: "Creating token ABC123..."
# Create token account
spl-token create-account <TOKEN_ADDRESS>
# Mint initial supply (1 million tokens)
spl-token mint <TOKEN_ADDRESS> 1000000Common Issues & Solutions
Issue 1: Bot doesn't respond
Solution: Check the bot token is correct in OASIS_DNA.json and the API is running
Issue 2: MongoDB connection error
Solution: Verify MongoDB connection string is correct
Issue 3: "Provider not activated"
Solution: Make sure TelegramOASIS provider is being activated in startup code
Issue 4: Karma not updating
Solution: Check that MongoDBOASIS is connected and avatar is being saved
Bot Commands Reference
/start
Link account to OASIS
/start
/creategroup <name>
Create accountability group
/creategroup Fitness Challenge
/joingroup <id>
Join existing group
/joingroup abc-123-def
/setgoal <description>
Set a new goal
/setgoal Exercise 30 min daily
/checkin <update>
Post progress
/checkin Completed workout!
/mystats
View your stats
/mystats
/mygroups
List your groups
/mygroups
/help
Show help message
/help
Configuration Options
In OASIS_DNA.json โ TelegramOASIS:
BotToken
Telegram bot API token
123456789:ABC...
WebhookUrl
URL for webhook (optional)
https://...
MongoConnectionString
MongoDB for social data
mongodb+srv://...
TreasuryWalletAddress
Solana wallet for rewards
Be51B1n...
RewardTokenMintAddress
SPL token mint address
Token123...
RewardTokenSymbol
Token symbol (display)
EXP
SolanaCluster
Solana network
devnet or mainnet-beta
Customizing Rewards
Edit group rules in database or modify defaults in Models/TelegramGroup.cs:
public class GroupRules
{
public int KarmaPerCheckin { get; set; } = 10; // Change this
public decimal TokenPerMilestone { get; set; } = 1.0m; // Change this
public int RequiredCheckinsPerWeek { get; set; } = 3; // Change this
}Architecture Flow
User sends /checkin
โ
TelegramBotService receives update
โ
Looks up user's OASIS avatar
โ
Adds check-in to achievement
โ
AchievementManager awards karma
โ
Avatar.Karma updated in MongoDB
โ
Bot sends confirmation messageDatabase Collections
TelegramOASIS creates these MongoDB collections:
telegram_avatars
Maps Telegram ID โ OASIS Avatar ID
Stores group memberships
telegram_groups
Group metadata and rules
Member and admin lists
achievements
Goals and milestones
Check-in history
Reward amounts
API Endpoints
Test with curl or Postman:
# Link Telegram account
curl -X POST http://localhost:5002/api/telegram/link-avatar \
-H "Content-Type: application/json" \
-d '{
"telegramId": 123456789,
"telegramUsername": "naali",
"firstName": "Naali"
}'
# Create group
curl -X POST http://localhost:5002/api/telegram/groups/create \
-H "Content-Type: application/json" \
-d '{
"name": "Fitness Group",
"createdBy": "avatar-guid-here",
"telegramChatId": 123456789
}'
# Get user stats
curl http://localhost:5002/api/telegram/achievements/user/{avatarId}Going to Production
When ready to launch:
Switch to Mainnet:
Change
SolanaClustertomainnet-betaUpdate
ConnectionStringinSolanaOASISconfigEnsure treasury wallet has sufficient tokens
Set Up Webhooks:
Get a public domain with HTTPS
Configure webhook URL
Bot will receive updates instantly instead of polling
Scale MongoDB:
Consider dedicated cluster
Set up indexes for performance
Enable backups
Monitor & Analytics:
Track active users
Monitor token distribution
Log achievement completions
Security:
Never commit bot token to git
Use environment variables for secrets
Set up admin authentication
Rate limit API endpoints
Support & Resources
Full Documentation:
NextGenSoftware.OASIS.API.Providers.TelegramOASIS/README.mdImplementation Details:
TELEGRAM_INTEGRATION_SUMMARY.mdOASIS Docs: Check
/DocsdirectoryTelegram Bot API: https://core.telegram.org/bots/api
Example Use Case: 30-Day Fitness Challenge
1. Admin creates group:
/creategroup 30 Day Fitness Challenge
2. Members join:
/joingroup abc-123-def
3. Each member sets goal:
/setgoal Complete 30 workouts in 30 days
4. Daily check-ins:
/checkin Day 1: 30 min cardio โ
(Earns +10 karma each time)
5. After 30 days:
Admin marks complete or auto-complete
User receives: +100 karma + 5 EXP tokens
6. Leaderboard:
/leaderboard
(Shows top performers)Next Steps
โ Get bot running locally
โ Test all commands
โณ Create SPL token on devnet
โณ Test token distribution
โณ Invite test users
โณ Gather feedback
โณ Launch on mainnet
Questions?
GitHub Issues: [Your repo]
Email: naali@experiences.fun
Telegram: @naali
Ready to build accountability groups on OASIS! ๐
Last updated