Skip to content

Commit 87c9912

Browse files
committed
feat: Move and rework Web3telegram integration guide to Web3Messaging in guides section
1 parent 3851738 commit 87c9912

File tree

4 files changed

+130
-118
lines changed

4 files changed

+130
-118
lines changed

.vitepress/sidebar.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ export function getSidebar() {
252252
text: 'Add Inputs to the Execution',
253253
link: '/guides/use-iapp/add-inputs-to-execution',
254254
},
255+
{
256+
text: 'Integrate Web3 Messaging',
257+
link: '/guides/use-iapp/web3-messaging',
258+
},
255259
{
256260
text: 'How to Pay the Executions',
257261
link: '/guides/use-iapp/how-to-pay-executions',
@@ -591,10 +595,7 @@ export function getSidebar() {
591595
},
592596
],
593597
},
594-
{
595-
text: 'Integration Guide',
596-
link: '/references/web3telegram/integration-guide',
597-
},
598+
598599
{
599600
text: 'Advanced Configuration',
600601
link: '/references/web3telegram/advanced-configuration',
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
title: Integrate Web3 Messaging (Web3Mail & Web3Telegram)
3+
description:
4+
End-to-end guide to send messages with Web3Mail (email) and Web3Telegram
5+
(Telegram) using iExec — protect identifiers, grant access, and send securely
6+
---
7+
8+
# Integrate Web3 Messaging
9+
10+
This guide covers both Web3Mail (email) and Web3Telegram (Telegram). The flow is
11+
the same, except that:
12+
13+
- For Web3Mail, you only need the user's email address.
14+
- For Web3Telegram, you must first retrieve the user's Telegram Chat ID.
15+
16+
## Overview
17+
18+
1. (Telegram only) Retrieve the Chat ID from the iExec bot
19+
2. Create the `protectedData` using DataProtector
20+
3. Grant access with DataProtector
21+
4. Send the message using the relevant SDK
22+
23+
## 1. Retrieve the Telegram Chat ID (Telegram only) {#retrieve-chat-id}
24+
25+
Ask the recipient to open Telegram and start a conversation with
26+
[@IExecWeb3TelegramBot](https://t.me/IExecWeb3TelegramBot). The bot replies with
27+
their unique Chat ID.
28+
29+
:::: tip
30+
31+
- Once the Chat ID is protected, all messages will arrive within this bot
32+
conversation.
33+
- The recipient can leave the conversation at any time to stop receiving
34+
messages. ::::
35+
36+
## 2. Create the Protected Data
37+
38+
Protect the identifier using DataProtector Core.
39+
40+
### Web3Mail — protect the email address
41+
42+
```ts twoslash
43+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
44+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
45+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
46+
47+
const protectedData = await dataProtectorCore.protectData({
48+
data: {
49+
50+
},
51+
});
52+
```
53+
54+
### Web3Telegram — protect the Chat ID
55+
56+
```ts twoslash
57+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
58+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
59+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
60+
61+
const protectedData = await dataProtectorCore.protectData({
62+
data: {
63+
telegram_chatId: '12345678',
64+
},
65+
});
66+
```
67+
68+
## 3. Grant Access
69+
70+
Grant permission for a sender and/or an app to contact the user.
71+
72+
```ts twoslash
73+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
74+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
75+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
76+
77+
const grantedAccess = await dataProtectorCore.grantAccess({
78+
protectedData: '0x123abc...',
79+
authorizedApp: '0x456def...',
80+
authorizedUser: '0x789cba...',
81+
pricePerAccess: 3,
82+
numberOfAccess: 10,
83+
});
84+
```
85+
86+
## 4. Send the Message
87+
88+
### Web3Mail — sendEmail
89+
90+
```ts twoslash
91+
import { IExecWeb3mail, getWeb3Provider } from '@iexec/web3mail';
92+
93+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
94+
const web3mail = new IExecWeb3mail(web3Provider);
95+
96+
const sendEmail = await web3mail.sendEmail({
97+
protectedData: '0x123abc...',
98+
emailSubject: 'My email subject',
99+
emailContent: 'My email content',
100+
// useVoucher: true,
101+
});
102+
```
103+
104+
### Web3Telegram — sendTelegram
105+
106+
```ts twoslash
107+
import { IExecWeb3telegram, getWeb3Provider } from '@iexec/web3telegram';
108+
109+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
110+
const web3telegram = new IExecWeb3telegram(web3Provider);
111+
112+
const sendTelegram = await web3telegram.sendTelegram({
113+
protectedData: '0x123abc...',
114+
senderName: 'Arthur',
115+
telegramContent: 'My telegram message content',
116+
// useVoucher: true,
117+
});
118+
```
119+
120+
## Payment
121+
122+
See the full payment guide:
123+
[/guides/use-iapp/how-to-pay-executions](/guides/use-iapp/how-to-pay-executions)

src/references/web3telegram.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ telegram chat ID recipients through use of Ethereum addresses.
1919
iExec's protocol the telegram chat ID as a `protectedData` entity using
2020
[iExec Data Protector](/references/dataProtector). Through this mechanism, users
2121
have complete control over which applications may use their
22-
[chat ID](/references/web3telegram/integration-guide#_1-get-your-users-to-retrieve-their-chat-id)
23-
for sending communications.
22+
[chat ID](/guides/use-iapp/web3-messaging#retrieve-chat-id) for sending
23+
communications.
2424

2525
Sending a user a message, therefore, requires knowledge of the Ethereum address
2626
of their `protectedData` as well as an explicit authorization for your account

src/references/web3telegram/integration-guide.md

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)