I am trying to create a "conversation history" page on my app, where you see the "participant's" name and the last message of the conversation (see attached image). I understand the image would have to come from another database.
I have most recently tried the following
Get a list of existing conversations for the logged in user using
client.conversations.users.userConversations.list()
Iterate over the number of conversations, and get the last message from each conversation and get participant data
participant = client.conversations.conversations(existingConversationSidAtIndex.conversationSid).messages.list({limit: 1})
AND
client.conversations.users(participant.accountSid).fetch()
- Map over those two datasets and merge the participant data with the last message data
There must be a more efficient way?