Skip to content

Commit f461716

Browse files
committed
readme update
1 parent 4ea5901 commit f461716

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

README.md

+31-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ This repository contains examples of agents that use the [XMTP](https://docs.xmt
1212

1313
> See [FAQ](https://docs.xmtp.org/intro/faq) for more detailed information.
1414
15-
## Environment variables
15+
## Getting started
16+
17+
### Environment variables
1618

1719
To run your XMTP agent, you must create a `.env` file with the following variables:
1820

@@ -30,7 +32,28 @@ yarn gen:keys
3032
> [!WARNING]
3133
> Running the `gen:keys` script will overwrite the existing `.env` file.
3234
33-
## Working with addresses
35+
### Fetching messages
36+
37+
There are to ways to fetch messages from a conversation, one is by starting a stream
38+
39+
```tsx
40+
const stream = client.conversations.streamAllMessages();
41+
42+
for await (const message of await stream) {
43+
/*You message*/
44+
}
45+
```
46+
47+
And by polling you can call all the messages at once, which we stored in your local database
48+
49+
```tsx
50+
/* Sync the conversations from the network to update the local db */
51+
await client.conversations.sync();
52+
// get message array
53+
await client.conversations.messages();
54+
```
55+
56+
### Working with addresses
3457

3558
Conversations in XMTP can be `DMs` or `Groups`. The underlying technicalities are the same, but DMs are essentially groups locked between two users that can be reused - basically a fixed group of 2. This is how MLS works.
3659

@@ -55,6 +78,12 @@ const address =
5578

5679
> XMTP is working on integrating passkeys as a pillar of identity. Expect a breaking change soon as XMTP prepares for the first v3 stable release.
5780
81+
## Web inbox
82+
83+
Interact with the XMTP network using [xmtp.chat](https://xmtp.chat), the official web inbox for developers.
84+
85+
![](/media/chat.png)
86+
5887
## Examples
5988

6089
- [gm](/examples/gm/): A simple agent that replies to all text messages with "gm".
@@ -70,9 +99,3 @@ Examples integrating XMTP with external libraries from the ecosystem
7099
- [grok](/integrations/grok/): Integrate XMTP to the Grok API
71100

72101
> See all the available [integrations](/integrations/).
73-
74-
## Web inbox
75-
76-
Interact with the XMTP network using [xmtp.chat](https://xmtp.chat), the official web inbox for developers.
77-
78-
![](/media/chat.png)

0 commit comments

Comments
 (0)