πŸ“• Get_messages

πŸ“• Get_messages

Added on version 23.1.0b13
get_messages(self, conversation_id: str, last_id: str | None = None) -> GetMessagesRequest.GetMessagesResponse | Error:
Fetch messages from a conversation.
This will return list of messages in conversation, at most 20 messages will be returned ordered from newest to the oldest. IfΒ last_idΒ is provided then only messages that are older than specified id will be returned. conversation_id must be from conversation that is available to bot.

βš™οΈ Use cases

Here we will use the get_message method to retrieve an specific conversation from the bot and store it in a variable called specific_conversation and then we will print it on terminal to see how the response from it looks like.
async def on_start(self, session_metadata: SessionMetadata) -> None: conversation_id = '1_on_1:6111e1fb22dcb50edf32e4a8:649b87f63cf84acc47487627' specific_conversation = await self.highrise.get_messages(conversation_id) print (specific_conversation)
Response:
GetMessagesRequest.GetMessagesResponse( messages=[ Message( message_id="64b0a27dfd1c588666bd2f00", conversation_id="1_on_1:6111e1fb22dcb50edf32e4a8:649b87f63cf84acc47487627", createdAt=datetime.datetime(2023, 7, 14, 1, 18, 53), content="Hello World!", sender_id="649b87f63cf84acc47487627", category="text", ), Message( message_id="64b0a27dfd1c588666bd2eef", conversation_id="1_on_1:6111e1fb22dcb50edf32e4a8:649b87f63cf84acc47487627", createdAt=datetime.datetime(2023, 7, 14, 1, 18, 53), content="Hello", sender_id="6111e1fb22dcb50edf32e4a8", category="text", ), ], rid="0", )
Β 
Built with Potion.so