Your transaction has been processed successfully.
| Amount: | 0.5 SOL |
| Fee: | 0.0025 SOL |
| Transaction ID: | 3x7Kj...9mNp |
View full details in your dashboard.
" } }' ```Your transaction has been processed successfully.
| Amount: | 0.5 SOL |
| Fee: | 0.0025 SOL |
| Transaction ID: | 3x7Kj...9mNp |
View full details in your dashboard.
` } }; await fetch(`https://alerts-api.dial.to/v2/${appId}/send`, { method: 'POST', headers: { 'x-dialect-api-key': 'YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify(emailNotification) }); ```| 📊 Current Price: | $145.50 |
| 🎯 Your Target: | $140.00 |
| 📈 Gain: | +3.9% |
Consider reviewing your position and taking action.
`, recipient: userWallet, addressTypes: [AddressType.Email], // HTML only works for email actionsV2 }; // Plain text version for IN_APP and Telegram const plainTextMessage = { title: "Price Alert: SOL Hit Your Target! 📈", message: ` Great news! Solana has reached your target price. 📊 Current Price: $145.50 🎯 Your Target: $140.00 📈 Gain: +3.9% Consider reviewing your position and taking action. `, recipient: userWallet, addressTypes: [AddressType.Telegram], // Plain text for non-email channels actionsV2 }; // Send both versions await dapp.messages.send(emailMessage); await dapp.messages.send(plainTextMessage); ``` ## Step 4: Topic-Based Messaging ### Send to Topic Subscribers If you've configured notification types/topics, you can send targeted messages to users who have subscribed to specific categories. ```typescript theme={null} // Send to users subscribed to a specific notification type const defiAlert = { title: "New DeFi Opportunity Available", message: "A new high-yield farming pool has been added with 15% APY.", notificationTypeId: "defi-alerts", // Your configured topic ID }; await dapp.messages.send(defiAlert); ``` ### Topic-Specific Content Tailor your message content to match the expectations of users who subscribed to specific topics. ```typescript theme={null} import { DappMessageActionType } from '@dialectlabs/sdk'; const actionsV2 = { type: DappMessageActionType.LINK, links: [{ label: "Vote Now", url: "https://yourapp.com/governance/proposals/123" }], }; // Governance topic notification const governanceUpdate = { title: "🗳️ New Governance Proposal: Protocol Upgrade", message: ` A new governance proposal is now live for voting: 📋 Proposal: Upgrade to V3 Protocol ⏰ Voting Period: 7 days remaining 📊 Current Status: 45% participation Your vote matters for the future of our protocol. `, notificationTypeId: "governance-updates", actionsV2, }; await dapp.messages.send(governanceUpdate); ``` ## Message Examples by Use Case ### Welcome Message ```typescript theme={null} import { DappMessageActionType } from '@dialectlabs/sdk'; const actionsV2 = { type: DappMessageActionType.LINK, links: [{ label: "Get Started", url: "https://yourapp.com/onboarding" }], }; const welcomeMessage = { title: "Welcome to [Your App]! 🎉", message: "Thanks for subscribing! You'll now receive important updates and alerts.", recipient: userWallet, actionsV2 }; await dapp.messages.send(welcomeMessage); ``` ### Transaction Alert ```typescript theme={null} import { AddressType } from '@dialectlabs/sdk'; const transactionAlert = { title: "Transaction Confirmed ✅", message: "Your 0.5 SOL transfer to 3x7Kj...9mNp has been confirmed.", recipient: userWallet, addressTypes: [AddressType.Email] // Also send email record }; await dapp.messages.send(transactionAlert); ``` ### Security Alert ```typescript theme={null} import { DappMessageActionType, AddressType } from '@dialectlabs/sdk'; const actionsV2 = { type: DappMessageActionType.LINK, links: [{ label: "Review Security", url: "https://yourapp.com/security" }], }; const securityAlert = { title: "🔒 Security Alert: New Login Detected", message: "A new login to your account was detected from a new device. If this wasn't you, please secure your account immediately.", recipient: userWallet, addressTypes: [AddressType.Email], // Ensure they get email notification actionsV2 }; await dapp.messages.send(securityAlert); ``` ### Price Alert ```typescript theme={null} import { DappMessageActionType } from '@dialectlabs/sdk'; const actionsV2 = { type: DappMessageActionType.LINK, links: [{ label: "View Portfolio", url: "https://yourapp.com/portfolio" }], }; const priceAlert = { title: "📈 Price Alert: SOL +12%", message: "Solana is up 12% in the last hour, now trading at $145. Your portfolio value has increased by $340.", notificationTypeId: "price-alerts", recipient: userWallet, actionsV2 }; await dapp.messages.send(priceAlert); ``` ## Best Practices 💡 **Message Design Tips**: * Keep titles concise and descriptive (especially important for email subjects) * Structure longer messages with clear sections * Always include clear calls-to-action when appropriate 💡 **Technical Tips**: * Test your messages across different channels (IN\_APP vs email vs Telegram) * Implement proper error handling and retry logic for critical notifications * Consider user time zones when sending time-sensitive notifications 💡 **User Experience Tips**: * Respect user preferences and subscription settings * Provide context in your messages - users should understand why they're receiving the notification * Use topic-based messaging to ensure relevance # Setup & Configuration Source: https://docs.dialect.to/alerts/send/sdk/setup-configuration Install and configure the Dialect TypeScript SDK for sending notifications from your Node.js and React applications Get the Dialect TypeScript SDK installed and configured in your environment. This guide covers installation, client setup, authentication, and environment configuration. ## Installation Install the core SDK and blockchain-specific packages for your needs: