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);