Skip to content

Instantly share code, notes, and snippets.

@DarraghB1992
Last active January 31, 2024 23:23
Show Gist options
  • Save DarraghB1992/f204a3752ebcfb6e104347980cf3dbb1 to your computer and use it in GitHub Desktop.
Save DarraghB1992/f204a3752ebcfb6e104347980cf3dbb1 to your computer and use it in GitHub Desktop.
Exporting Saved Replies from Intercom into a CSV file

Prerequisites

Python 2.7.x

A basic knowledge of how to move through folders using the terminal/command prompt

Step 1

Head to https://app.intercom.io/ember/saved_replies.json?app_id=YOUR_APP_ID to get the json containing all of your apps saved replies

Step 2

Create a new folder, lets call it saved_reply_converter on your computer somewhere that you can easily navigate to using the terminal. Copy and paste all of your saved replies into file a new file in this folder, lets call it saved_replies.json.

Step 3

Lets create a new python file now to run our script. Let's call it convert_saved_replies.py Inside convert_saved_replies.py paste the following code snippet. This snippet assumes you used the names outlined in the previous steps.

import json
import csv

saved_replies = 'saved_replies.json'

with open(saved_replies) as json_data:
    d = json.load(json_data)

starting_point = d['saved_replies']

f=csv.writer(open('saved_replies.csv','wb+'))


for x in starting_point: 
	f.writerow([x['name'].encode('utf-8'), x['html'].encode('utf-8')])


print "Complete"

Step 4

Once you have added the code to convert_saved_replies.py and saved the file head over to you terminal and cd into the saved_reply_converter folder that contains both of our files.

Once in that folder running python convert_saved_replies.py should create a new csv file named saved_replies.csv.

Step 5

You should now have a CSV file containing all of your saved replies! Upload it to Google sheets or import to Excel from here. This content of the saved replies will contain some HTML but its a great start!

@tonijeto
Copy link

Hello,

Thank you for this script. I have done everything you wrote but I am not able to create CSV file. Do you have any idea what is the problem?

Thank you again.
Regards

@lekansogunle
Copy link

This script does not work!

You can change x['html'] to x['summary'] to extract the name and summary of replies in the csv

@lekansogunle
Copy link

lekansogunle commented Dec 11, 2019

@tonijeto

I created a new script here on this gist https://gist.github.com/lekansogunle/65a740e43fd2b01deced1b2d3bc4ab83

This works by creating a csv with title, summary and conversation details.

@rtugovasdco
Copy link

rtugovasdco commented Oct 5, 2020

Hi @lekansogunle

Is the API still working? I have tried via Python script or just entering the URL in a browser, but always getting {"error":"You need to sign in or sign up before continuing."}

UP: https://app.intercom.io didn't work for me. but https://app.intercom.COM is ok.

@maneeshsethi
Copy link

Hi @lekansogunle

Is the API still working? I have tried via Python script or just entering the URL in a browser, but always getting {"error":"You need to sign in or sign up before continuing."}

UP: https://app.intercom.io didn't work for me. but https://app.intercom.COM is ok.

Thank you for this! I couldn't figure this out until your comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment