Skip to content

Commit d75eefb

Browse files
committed
docs(docs): 📝 update docs for dm events
1 parent e20e66b commit d75eefb

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

docs/docs/usage/direct-messages/direct-messages-lookup.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,35 @@ Direct Messages enable private conversations on Twitter. Direct Messages are one
44

55
You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/direct-messages/lookup/introduction)
66

7-
###
7+
### Get all messages in a 1-1 conversation
88

9+
Returns a list of Direct Messages (DM) events within a 1-1 conversation with the user specified in the participant_id path parameter.
910

10-
Returns a list of Direct Messages (DM) events within a 1-1 conversation with the user specified in the participant_id path parameter.
11+
Messages are returned in reverse chronological order.
12+
13+
```python
14+
my_api.get_dm_events_by_participant("1334059193268011010", max_results=1)
15+
# Response(data=[DirectMessageEvent(id='1593226322066567177', event_type='MessageCreate', text='from api to III')])
16+
```
17+
18+
### Get all messages in a specific conversation (both group and 1-1 conversations)
19+
20+
Returns a list of Direct Messages within a conversation specified in the dm_conversation_id path parameter.
21+
22+
Messages are returned in reverse chronological order.
23+
24+
```python
25+
my_api.get_dm_events_by_conversation("1593091374437781506", max_results=1)
26+
# Response(data=[DirectMessageEvent(id='1593091374437781510', event_type='MessageCreate', text='New group by api')])
27+
```
28+
29+
### Get all messages across a user's DM conversations (both sent and received, group and 1-1 conversations)
30+
31+
Returns a list of Direct Messages for the authenticated user, both sent and received. Direct Message events are returned in reverse chronological order.
32+
33+
Supports retrieving events from the previous 30 days.
34+
35+
```python
36+
my_api.get_dm_events(max_results=2)
37+
# Response(data=[DirectMessageEvent(id='1593226454237487108', event_type='MessageCreate', text='from api to III'), DirectMessageEvent(id='1593226322066567177', event_type='MessageCreate', text='from api to III')])
38+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Manage Direct Messages
2+
3+
Direct Messages enable private conversations on Twitter. Direct Messages are one of the most popular features of Twitter, with a wide variety of use cases. These use cases range from group chats among friends, to powering customer support for brands around the world. New v2 versions of Direct Messages endpoints will be introduced in stages, and this first stage includes fundamental endpoints for creating Direct Messages and listing Direct Message conversation events. For the first time, the Twitter API v2 supports group conversations.
4+
5+
You can get more information for this at [docs](https://developer.twitter.com/en/docs/twitter-api/direct-messages/manage/introduction)
6+
7+
8+
### Create a message in a 1-1 conversation with the participant
9+
10+
Creates a one-to-one Direct Message and adds it to the one-to-one conversation.
11+
12+
This method either creates a new one-to-one conversation or retrieves the current conversation and adds the Direct Message to it.
13+
14+
```python
15+
my_api.create_message_to_participant("1334059193268011010", text="dm by api")
16+
# DirectMessageCreateResponse(dm_conversation_id='1301152652357595137-1334059193268011010', dm_event_id='1593234034146279428')
17+
```
18+
19+
### Create a group conversation and add a DM to it
20+
21+
Creates a Direct Message on behalf of an authenticated user, and adds it to the specified conversation.
22+
23+
```python
24+
my_api.create_message_to_conversation("1593091374437781506", text="message by api")
25+
# DirectMessageCreateResponse(dm_conversation_id='1301152652357595137-1334059193268011010', dm_event_id='1593234034146279428')
26+
```
27+
28+
### Adding a DM to an existing conversation (for both group and 1-1)
29+
30+
Creates a new group conversation and adds a Direct Message to it on behalf of an authenticated user.
31+
32+
```python
33+
my_api.create_conversation(
34+
conversation_type="group",
35+
message={"text": "hello"},
36+
participant_ids=["1334059193268011010", "906948460078698496"]
37+
)
38+
# DirectMessageCreateResponse(dm_conversation_id='1301152652357595137-1334059193268011010', dm_event_id='1593234034146279428')
39+
```

docs/mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ nav:
6262
- Pinned Lists: usage/lists/pinned-lists.md
6363
- Compliance:
6464
- Batch compliance: usage/compliance/batch_compliance.md
65+
- Direct Messages:
66+
- Direct Messages lookup: usage/direct-messages/direct-messages-lookup.md
67+
- Manage Direct Messages: usage/direct-messages/manage-direct-messages.md
6568
- Steaming: usage/streaming.md
6669
- Changelog: CHANGELOG.md
6770

0 commit comments

Comments
 (0)