Skip to content

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 0x192C6f5AccE52c81Fcc2670f10611a3665AAA98F as authorizedApp. Refer to the Data Protector grantAccess documentation for more details.

TIP

For executing the sendTelegram method with a voucher or xRLC, refer to the dedicated section in the documentation under "How to Pay for web3telegram".

Usage

ts

const 
sendTelegram
= await
web3telegram
.
sendTelegram
({
protectedData
: '0x123abc...',
telegramContent
: 'My telegram message content',
senderName
: 'Awesome project team',
label
: 'some-cutom-id',
workerpoolAddressOrEns
: 'prod-v8-bellecour.main.pools.iexec.eth',
dataMaxPrice
: 42,
appMaxPrice
: 42,
workerpoolMaxPrice
: 42,
});

Parameters

ts
import { type 
SendTelegramParams
} from '@iexec/web3telegram';

protectedData

Address

The address of the protectedData holding the contact's telegram chat ID.

ts

const 
sendTelegram
= await
web3telegram
.
sendTelegram
({
protectedData
: '0x123abc...',
senderName
: 'Arthur',
telegramContent
: 'My telegram message content',
});

senderName

string

The name of the telegram message sender.

ts

const 
sendTelegram
= await
web3telegram
.
sendTelegram
({
protectedData
: '0x123abc...',
senderName
: 'Arthur',
telegramContent
: 'My telegram message content',
});

telegramContent

string

maximum size: 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.

ts

const 
sendTelegram
= await
web3telegram
.
sendTelegram
({
protectedData
: '0x123abc...',
senderName
: 'Arthur',
telegramContent
: 'My telegram message content',
});

useVoucher 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.

ts

const 
sendTelegram
= await
web3telegram
.
sendTelegram
({
protectedData
: '0x123abc...',
telegramContent
: 'My telegram message content',
senderName
: 'Awesome project team',
label
: 'some-cutom-id',
workerpoolAddressOrEns
: 'prod-v8-bellecour.main.pools.iexec.eth',
dataMaxPrice
: 42,
appMaxPrice
: 42,
workerpoolMaxPrice
: 42,
useVoucher
: true,
});

TIP

If your voucher doesn't have enough xRLC 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

string | undefined

Allows adding a custom public label. The Web3telegram tool writes this onchain as iexec_args in the deal params.

ts

const 
sendTelegram
= await
web3telegram
.
sendTelegram
({
protectedData
: '0x123abc...',
senderName
: 'Arthur',
telegramContent
: 'My telegram message content',
label
: 'some-cutom-id',
});

workerpoolAddressOrEns

workerpoolAddressOrEns | undefined

default: iExec's production workerpool

Allows specifying the workerpool that will run the Web3Telegram application.

ts

const 
sendTelegram
= await
web3telegram
.
sendTelegram
({
protectedData
: '0x123abc...',
senderName
: 'Arthur',
telegramContent
: 'My telegram message content',
workerpoolAddressOrEns
: 'prod-v8-bellecour.main.pools.iexec.eth',
});

TIP

iExec currently offers a production workerpool located at the Ethereum Name Service (ENS) address prod-v8-bellecour.main.pools.iexec.eth. This is the default workerpool for running confidential computations on the iExec platform.

dataMaxPrice

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.

ts

const 
sendTelegram
= await
web3telegram
.
sendTelegram
({
protectedData
: '0x123abc...',
senderName
: 'Arthur',
telegramContent
: 'My telegram message content',
dataMaxPrice
: 42,
});

appMaxPrice

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.

ts

const 
sendTelegram
= await
web3telegram
.
sendTelegram
({
protectedData
: '0x123abc...',
senderName
: 'Arthur',
telegramContent
: 'My telegram message content',
appMaxPrice
: 42,
});

workerpoolMaxPrice

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.

ts

const 
sendTelegram
= await
web3telegram
.
sendTelegram
({
protectedData
: '0x123abc...',
senderName
: 'Arthur',
telegramContent
: 'My telegram message content',
workerpoolMaxPrice
: 42,
});

Return value

ts
import { type 
SendTelegramResponse
} from '@iexec/web3telegram';

taskId

Addess

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 Explorer.