import { DappMessageActionType, AddressType } from '@dialectlabs/sdk';
const actionsV2 = {
type: DappMessageActionType.LINK,
links: [{
label: "View Portfolio",
url: "https://yourapp.com/portfolio"
}],
};
// Rich HTML content for email channel
const emailMessage = {
title: "Price Alert: SOL Hit Your Target! π",
message: `
<h2>π Great news! Solana has reached your target price.</h2>
<table style="width: 100%; border-collapse: collapse; margin: 20px 0;">
<tr>
<td style="padding: 10px; border: 1px solid #ddd;"><strong>π Current Price:</strong></td>
<td style="padding: 10px; border: 1px solid #ddd;">$145.50</td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #ddd;"><strong>π― Your Target:</strong></td>
<td style="padding: 10px; border: 1px solid #ddd;">$140.00</td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #ddd;"><strong>π Gain:</strong></td>
<td style="padding: 10px; border: 1px solid #ddd; color: green;">+3.9%</td>
</tr>
</table>
<p><em>Consider reviewing your position and taking action.</em></p>
`,
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);