Hey everyone
My name is Ivan and I’m a Customer Support Engineer here at Intercom. You might’ve seen my face around if you messaged our support via the Messenger ♂️
Here’s a sample Python scrip you can use to copy your articles from your US to your EU workspace
import requests
# set parameters for US and EU endpoints/headers
intercom_token_us = "<YOUR US TOKEN GOES HERE>"
intercom_token_eu = "<YOUR EU TOKEN GOES HERE>"
intercom_us_url = "https://api.intercom.io/articles"
intercom_eu_url = "https://api.eu.intercom.io/articles"
# header used to get the articles from US workspace
intercom_headers_us = {
"Authorization": "Bearer " + intercom_token_us,
"Accept": "application/json",
"Content-Type": "application/json",
}
# header used to create the articles in EU workspace
intercom_headers_eu = {
"Authorization": "Bearer " + intercom_token_eu,
"Accept": "application/json",
"Content-Type": "application/json",
}
# store all articles in a list
articles = e]
# get all articles from the old help center
def get_articles():
response = requests.request("GET", intercom_us_url, headers=intercom_headers_us)
articles = response.json()
return articleso"data"]
# create a new article in the new help center
def create_article(article):
# gets title, body and author ID from the article
# Note: assumes all articles have a title (required field)
payload = {
"title": articleb"title"],
"body": article<"body"],
# Note: Admin ID in your US workspace is different to your Admin ID in your EU workspace
"author_id": "<ADMIN ID GOES HERE>"
}
response = requests.post(intercom_eu_url, headers=intercom_headers_eu, json=payload)
# check if the article was created successfully
if response.status_code == 200:
print("Article created successfully")
else:
print("Article creation failed")
print(response.text.encode('utf8'))
# loop over the articles list and create each article in the new help center
def migrate_articles():
articles = get_articles()
for article in articles:
create_article(article)
migrate_articles()
Couple of important things to note here:
- You must replace the
YOUR X TOKEN GOES HERE
with your actual US and EU/AU API tokens. You can get these by creating an app on our Developer Hub - Articles must have a title, otherwise they won’t be migrated
- You must replace
ADMIN ID GOES HERE
with an actual Admin ID in your EU/AU workspace. Note that Admin IDs in EU/AU and US workspaces are different. You can find your Admin ID by looking at the browser URL bar while in the Inbox
-
If you’re looking to migrate Articles to AU workspace, you must change the endpoint from
https://api.eu.intercom.io/articles
tohttps://api.au.intercom.io/articles
Hope you find this useful!