sendTelegram
This method allows an authorized entity to send a telegram message to a User without needing to know their username or Chat ID.
The recipient Chat ID is stored in a protectedData
entity. The user receiving message must explicitly authorize you to send them telegram communications and permission must be granted for the Web3Telegram
tool to use the protectedData
entity containing their chat ID. This is best done by granting authorization to the Web3Telegram app whitelist 0x53AFc09a647e7D5Fa9BDC784Eb3623385C45eF89
as authorizedApp
. Refer to the Data Protector grantAccess
documentation for more details.
TIP
For executing the sendTelegram
method with a voucher or RLC, refer to the dedicated section in the documentation under "How to Pay for Executions".
Usage
const sendTelegram = await web3telegram.sendTelegram({
protectedData: '0x123abc...',
telegramContent: 'My telegram message content',
senderName: 'Awesome project team',
label: 'some-custom-id',
dataMaxPrice: 42,
appMaxPrice: 42,
workerpoolMaxPrice: 42,
});
Parameters
import { type SendTelegramParams } from '@iexec/web3telegram';
protectedData
Type: Address
The address of the protectedData
holding the contact's telegram chat ID.
const sendTelegram = await web3telegram.sendTelegram({
protectedData: '0x123abc...',
senderName: 'Arthur',
telegramContent: 'My telegram message content',
});
senderName
Type: string
The name of the telegram message sender.
const sendTelegram = await web3telegram.sendTelegram({
protectedData: '0x123abc...',
senderName: 'Arthur',
telegramContent: 'My telegram message content',
});
telegramContent
Type:string
Maximum siz: 512 kb
The telegram message content that needs to be sent. The content is limited to 512 kb in size. Telegram content is encrypted and stored in IPFS.
const sendTelegram = await web3telegram.sendTelegram({
protectedData: '0x123abc...',
senderName: 'Arthur',
telegramContent: 'My telegram message content',
});
useVoucher Chain Not Supported Optional
Type: boolean
Default: false
This optional param allows you to pay for the deal using your voucher. Make sure that your voucher is held by your connected wallet.
const sendTelegram = await web3telegram.sendTelegram({
protectedData: '0x123abc...',
telegramContent: 'My telegram message content',
senderName: 'Awesome project team',
label: 'some-custom-id',
dataMaxPrice: 42,
appMaxPrice: 42,
workerpoolMaxPrice: 42,
useVoucher: true,
});
TIP
If your voucher doesn't have enough RLC to cover the deal, the SDK will automatically get the required amount to your iExec account. Ensure that your voucher is authorized to access your iExec account and that your account has sufficient funds for this transfer to proceed.
label
Type: string | undefined
Allows adding a custom public label. The Web3telegram tool writes this onchain as iexec_args
in the deal params.
const sendTelegram = await web3telegram.sendTelegram({
protectedData: '0x123abc...',
senderName: 'Arthur',
telegramContent: 'My telegram message content',
label: 'some-custom-id',
});
workerpoolAddressOrEns
Type: workerpoolAddressOrEns | undefined
Default: 0x2C06263943180Cc024dAFfeEe15612DB6e5fD248
(iExec's workerpool)
Allows specifying the workerpool that will run the Web3Telegram application.
const sendTelegram = await web3telegram.sendTelegram({
protectedData: '0x123abc...',
senderName: 'Arthur',
telegramContent: 'My telegram message content',
workerpoolAddressOrEns: '0xa5de76...',
});
dataMaxPrice
Type: number | undefined
Default: 0
Allows specifying the maximum amount (in nRLC) you are willing to pay the telegram chat ID owner for using their data. The owner of the protected chat ID receives this as a payment for sharing their data.
const sendTelegram = await web3telegram.sendTelegram({
protectedData: '0x123abc...',
senderName: 'Arthur',
telegramContent: 'My telegram message content',
dataMaxPrice: 42,
});
appMaxPrice
Type: number | undefined
Default: 0
Allows specifying the maximum amount (in nRLC) you are willing to pay the Web3telegram app provider (iExec) for using the Web3telegram application.
const sendTelegram = await web3telegram.sendTelegram({
protectedData: '0x123abc...',
senderName: 'Arthur',
telegramContent: 'My telegram message content',
appMaxPrice: 42,
});
workerpoolMaxPrice
Type: number | undefined
Default: 0
Allows specifying the maximum amount you want to pay the workerpool provider for using their infrastructure to run the web3telegram app in nRLC.
const sendTelegram = await web3telegram.sendTelegram({
protectedData: '0x123abc...',
senderName: 'Arthur',
telegramContent: 'My telegram message content',
workerpoolMaxPrice: 42,
});
Return Value
import { type SendTelegramResponse } from '@iexec/web3telegram';
taskId
Type: Address
This uniquely identifies the telegram task on the iExec side chain. You can view the status of the sendTelegram
method by monitoring the task on the iExec blockchain explorer .