์
๋ฌด ์ค Helpdesk ์ฝํ
์ธ ๋ผ๊ณ ํ์ฌ FAQ ๊ด๋ จํ์ฌ ์์ฑํ๋ ์ฝํ
์ธ ๊ฐ ์๋ค
์ธ๊ตญ ํ๋ซํผ Zendesk๋ฅผ ์ฌ์ฉํ๋๋ฐ, ํฌํ๋ฐ์คํฌ ์ฝํ
์ธ ๋ฅผ Articles ์ด๋ผ๊ณ ๋ถ๋ฅด๋ฉฐ
์ ํ ๋ณ๋ก ๋ธ๋๋๋ฅผ ์ถ๊ฐํ์ฌ ๊ฐ๊ฐ์ ์ฝํ
์ธ ๋ฅผ ๊ด๋ฆฌํ ์ ์๋ค.
์ข์ ํ๋ซํผ์ด ์์์๋ ๋ถ๊ตฌํ๊ณ ๋ด๋ถ์ ์ผ๋ก๋ ์๋ฐฑ ๊ฐ์ ์ฝํ
์ธ ๋ฆฌ์คํธ๋ฅผ
๊ด๋ฆฌํ๊ธฐ๊ฐ ๋ถํธํ ์ํฉ์ด ๋ฐ์ํ์๊ณ ๊ฒฐ๋ก ์ ์ผ๋ก ๋ฌธ์๋ก ๋ณด๊ดํ๋ ค๋ฉด Export๊ฐ ํ์ํ๋ค๊ณ ์๊ฐํ๋ค
์ฝ๊ฒ ๊ฐ์ ธ์ค๋ ๋ฐฉ๋ฒ์ ๊ตฌํํ๊ธฐ๋ก ๋ง ๋จน์๋ค
์ด์์ ๊ธํ ๋ง์ ๋์ ๋ณด์ด๋ Python์ผ๋ก ๊ตฌํ ํ์๊ณ ํด๋น ๋ฐฉ๋ฒ์ ๊ณต์ ํ๋ คํ๋ค.
๊ฐ ๋ธ๋๋๋ณ Articles์ ์ด๋ป๊ฒ ๋ถ๋ฌ์ค๋์ง ๋ชฐ๋ผ 3์๊ฐ์ ๊ณ ๋ฏผํ๋๋ฐ
๊ฒ์ํด์ ์ฐพ๊ธด ์ด๋ ค์ ์ง๋ง ์๊ณ ๋ณด๋ฉด ์ฌ์ด ๋ถ๋ถ์ด๋ผ ํด๋น ๋ด์ฉ์ ๊ณต์ ํ๊ณ ์ ํ๋ค
(*2๋ฒ ์ฐธ์กฐ ํ 1๋ฒ)
0. ์์ํ๊ธฐ ์
Zendesk API ๊ฐ์ด๋ (Help center) : https://developer.zendesk.com/rest_api/docs/help_center/articles
๊ฐ๋ฐ ํด : vs code
์ฌ์ฉ ์ธ์ด : python , json
1. ํน์ ๋ธ๋๋ Articles ์ถ์ถํ๊ธฐ ( .csv )
import requests
import sys
import io
import os
import datetime
import csv
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'euc-kr')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'euc-kr')
# Credentials, please set to correct username and password
credentials = 'ID์ ๋ณด', '๋น๋ฐ๋ฒํธ'
# Your Zendesk URL
# ๋ธ๋๋ domain ๊ธฐ์ฌ : ๋ธ๋๋๋ณ ์ฃผ์๋ฅผ ์์์ผ ํด๋น articles์ ๊ฐ์ ธ์ฌ ์ ์์
zendesk = 'https://{site-domain}.zendesk.com'
#index ์ฒ๋ฆฌ
idx = 1
language = 'ko'
# Makes backup path
date = datetime.date.today()
backup_path = os.path.join(str(date), language)
if not os.path.exists(backup_path):
os.makedirs(backup_path)
# For CSV logging
log = []
articles = zendesk + '/api/v2/help_center/{locale}/articles.json'.format(locale=language.lower())
sections = zendesk + '/api/v2/help_center/{locale}/sections.json'.format(locale=language.lower())
categories = zendesk + '/api/v2/help_center/{locale}/categories.json'.format(locale=language.lower())
# First retrive the sections and categories JSON data
response = requests.get(sections, auth=credentials)
if response.status_code != 200:
print('Failed to retrieve sections with error {}'.format(response.status_code))
exit()
sections = response.json()
response = requests.get(categories, auth=credentials)
if response.status_code != 200:
print('Failed to retrieve categories with error {}'.format(response.status_code))
exit()
categories = response.json()
# Begin the article process
while articles:
response = requests.get(articles, auth=credentials)
if response.status_code != 200:
print('Failed to retrieve articles with error {}'.format(response.status_code))
exit()
data = response.json()
for article in data['articles']:
if article['body'] is None:
continue
#ํ์ฑํ๋ ๊ฒ์๋ฌผ๋ง ๋ณด๊ธฐ
if article['draft'] == True:
continue
for section in sections['sections']:
if section['id'] == article['section_id']:
sectionsname = section['name']
categoriesid = section['category_id']
for category in categories['categories']:
if category['id'] == categoriesid:
categoriesname = category['name']
print('{id} copied!'.format(id=article['id']))
#ํ์ํ ์ ๋ณด (์ค์ )
log.append((idx, categoriesname, sectionsname, article['title'], article['body'], article['html_url'], article['created_at'], article['edited_at']))
idx = idx + 1
articles = data['next_page']
# Write to CSV
filename = 'zendesk.csv'
with open(os.path.join(backup_path, filename), mode='w', encoding='utf-8') as f:
writer = csv.writer(f)
#์ค์ ํ์ผ์ ์ธ๋ ๊ฐ ํ๋ title
writer.writerow( ('idx', 'Category', 'Section', 'Title', 'Body', 'Url', 'Create_date', 'Update_date') )
for article in log:
writer.writerow(article)
2. ๋ธ๋๋ ๋ณ ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ
#brands ๋๋ฉ์ธ ๋ถ๋ฌ์ค๊ธฐ
zendesk = 'https://{root-domain}.zendesk.com' #์ ๋ฐ์คํฌ ๋ธ๋๋ ๋๋ฉ์ธ ์
๋ ฅ
#brand๋ณ ๋๋ฉ์ธ์ ์ฐพ์์ผ ๊ฐ ์ ํ articles์ ๋ํ request๋ฅผ ๋ฐ์ ์ฌ ์ ์๋ค.
brands = zendesk + '/api/v2/brands.json'.format(locale=language.lower())
response = requests.get(brands, auth=credentials)
if response.status_code != 200:
print('Failed to retrieve sections with error {}'.format(response.status_code))
exit()
#๋ธ๋๋ ์ ๋ณด ํ์ธํ๋ json
brands = response.json()
3. HTML ํํ๋ก ์ ์ฅํ๊ธฐ
# Reserved for HTML processing
title = '<h1>' + article['title'] + '</h1>'
filename = '{id}.html'.format(id=article['id'])
with open(os.path.join(backup_path, filename), mode='w', encoding='utf-8') as f:
f.write(title + '\n' + article['body'])
! ์ต์ข ์ฃผ์์
1. brands๊ฐ ์ฌ๋ฌ๊ฐ์ผ ๊ฒฝ์ฐ ๊ฐ ๋ธ๋๋๋ณ domain์ผ๋ก ๋ฑ๋กํด์ผํ๋ค. ๋จ, ์ ํํ domain ์ ๋ณด๋ json์ ํตํด ๋ฐ์์์ผ ํ๋ค
2. ๋๋ mac์์ ๊ตฌํํ์๋๋ฐ windows์์ csv๋ฅผ excel๋ก ์ด ๊ฒฝ์ฐ ์ธ์ฝ๋ฉ ์ค๋ฅ๊ฐ ์กด์ฌํ๋ค
๋์ ์ต์ข ๋ชฉ์ ์ dbํ ์์ผ์ ์ถ๊ฐ/์ญ์ ๊น์ง ๊ด๋ฆฌ๊ฐ ๊ฐ๋ฅํ๊ณ , CS ํด์ ์ ๋ น์ฌ ์ฌ์ฉ ๋์์ผ๋ฉด ์ข๊ฒ ๋ค
'๋์งํธ ๊ฟํ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Datadog] API ์ฐ๋ํ์ฌ Log ์ถ์ถ ํ ๋ฆฌํฌํ ์๋ํ - 1๋จ๊ณ (0) | 2022.02.09 |
---|---|
[google spreadsheet & app script] PDF ์ฒจ๋ถํ์ฌ ๋ฉ์ผ ๋ณด๋ด๊ธฐ (0) | 2022.02.03 |
[Slack ์ฐ๋] ํน์ ์ฑ๋์ ๋ฉ์์ง ์ ์ก (0) | 2022.02.03 |
๋๊ธ