Exporting Conversations via API
GET /conversation/export
/conversation/export
can be used to regularly export all conversation data from Decagon. This endpoint returns up to 100 conversations at a time, along with all messages, customer ratings, tags, and other metadata associated with each of those conversations.
Parameters:
All parameters below are optional!
-
cursor: To get subsequent pages of conversations, pass in the value returned as
next_page_cursor
from a prior call. Leave this blank to get the oldest conversations. -
min_timestamp: The minimum timestamp at which a conversation was last updated. Note that this should be an integer representing the number of seconds since 1970-01-01. In Python, you can get a timestamp by doing
datetime.now().timestamp()
. -
max_timestamp: The maximum timestamp at which a conversation was last updated. Note that this should be an integer representing the number of seconds since 1970-01-01. In Python, you can get a timestamp by doing
datetime.now().timestamp()
. -
user_filters: Filters to apply to the export, which is stringified JSON. Currently the only filter supported is the metadata filter. To retrieve all records from a user with a specific email set in metadata, use this filter
{"metadata_filter": {"email": "jane@doe.com"}}
.
You might often get duplicate conversation even if you query with min and max timestamps that don’t overlap. Let’s say it is currently Jan 1 at 10am, and you query for all conversations from Dec 31 at 10am to Jan 1 at 10am. Now, tomorrow (Jan 2 at 10am) you query for all conversations from Jan 1 at 10am to Jan 2 at 10am — this could return some conversations that were returned the prior day as well, if those conversations had new messages added to them in the intervening 24 hour period!
Make sure you handle updating duplicates correctly!
Returns:
-
conversations: An array of conversations, along with all messages, customer ratings, tags, and other metadata associated with each of those conversations.
-
next_page_cursor: A value that can be passed in to a future call to this endpoint to get the next page of conversations. This value will be None if there are no more conversations to return.
Example Response:
Conversations will be “updated” (and hence show up in future calls to this endpoint) if they receive new messages. Make sure to deduplicate in your code appropriately.
Example code:
Here is some example code that could be used to export all conversations from Decagon: