Skip to main content

Copying your articles from US to EU/AU workspace


Ivan Branimir
Employee

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 = []

# 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 articles["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": article["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! 

2 replies

  • New Participant
  • 1 reply
  • August 25, 2023

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 ?


Ivan Branimir
Employee

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! 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings