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

INFO

For sending bulk campaigns to multiple recipients, use prepareTelegramCampaign and sendTelegramCampaign.

TIP

For executing the sendTelegram method with RLC, refer to the dedicated section in the documentation under "How to Pay for Executions".

Usage

ts

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

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

protectedData

Type: 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

Type: string

The name of the telegram message sender.

ts

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.

ts

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

label

Type: 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-custom-id',
});

workerpoolAddressOrEns

Type: workerpoolAddressOrEns | undefined

Default: 0x2C06263943180Cc024dAFfeEe15612DB6e5fD248 (iExec's 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
: '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.

ts

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.

ts

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.

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

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