Copying your articles from US to EU/AU workspace | Community
Skip to main content

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:

  1. 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 
  2. Articles must have a title, otherwise they won’t be migrated
  3. 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 👇
How to find your admin ID
  1. If you’re looking to migrate Articles to AU workspace, you must change the endpoint from https://api.eu.intercom.io/articles to https://api.au.intercom.io/articles

 

Hope you find this useful! 

Hello @Ivan Branimir 
Thanks for the script, do you have by any chance a collection of useful scripts like this to assist a US to EU migration ? (sorry if this is a bit off-topic) Is it possible to have some sort of community wiki for those practices ?


Hey @Cyril D 👋

 

That’s a brilliant idea - I’ll keep it in mind and hopefully I’ll get some time to post a few more of these to build up a library of these 😀

 

We do have a migration playbook that can aid you in migrating from US to EU workspaces if you're interested. Feel free to DM me your email address and I can send it over to you! 


@Ivan Branimir Unfortunately this won’t be enough to migrate properly from the US workspace to the EU/AU workspace. When grabbing the articles, all attachments (images, attachments) have a URL that has been ingested by Intercom and that references the particular US workspace. When re-creating the articles, if Intercom sees an “ingested by intercom” URL, it will not try to re-ingest it again, keeping the same URL. This will result in having all attachments and images pointing to the previous workspace, which will then be deleted when the workspace is deleted. 
The workaround is to grab everything in each article, upload it temporarily in an S3 bucket, a google drive or anything like that, ensuring that the URL changes and then re-create the articles with the new attachment/image URLs. It’s a bit more complex than just a simple export/import but nothing too complicated! 


Reply