#api

Problem with Retrieving Full Conversation Messages via API

TLDR noez_ inquired about ways to obtain all messages in a conversation for transcription. sojan_official explained that the API uses pagination to limit results to 20 messages at a time, and they discussed potential improvements to the system.

Powered by Struct AI
5
17mo
Solved
Join the chat
Jul 25, 2022 (17 months ago)
noez_
Photo of md5-11977b36f33267adee0b9ae1179bfa5c
noez_
10:29 AM
Is there a method to reliably get all messages of a conversation to be able to make a transcript by yourself for example?

1. the webhook that informs about the status change of a conversation only provides the last message.

2. /api/v1/accounts/X/conversations/X also returns only the last message, although the documentation explicitly says "with all messages in the conversation".

3. /api/v1/accounts/X/conversations/X/messages also says "List all messages of a conversation" but it shows a maximum of 20 messages.
sojan_official
Photo of md5-788237a2af5ff191b07ee9f215706ead
sojan_official
03:15 PM
api/accounts/x/conversations/x/messages supports pagination .. you would have to iterate over it since it only returns messages in batches of 20. using the params before which accepts a message id
noez_
Photo of md5-11977b36f33267adee0b9ae1179bfa5c
noez_
07:51 PM
The "before" method is very cumbersome for long conversations in my opinion. Also, the API documentation contradicts itself with "all messages".
Jul 26, 2022 (17 months ago)
sojan_official
Photo of md5-788237a2af5ff191b07ee9f215706ead
sojan_official
09:25 AM
We can look at implementing an additional limit parameter than the hardcoded 20 limit. But leaving that endpoint open with out pagination will have implications like super high response times and higher resource utilisation. ( loading all the message with the associated records like attachments )

and the current API was build for the Chatwoot conversation UI , where we fetch additional messages on scroll.
Jul 29, 2022 (17 months ago)
noez_
Photo of md5-11977b36f33267adee0b9ae1179bfa5c
noez_
11:00 AM
Great, thanks.