Script to import HTML files into Zendesk Forums

 Weeks ago, I was given with a task to import bunch of HTML files into Zendesk Forum as articles. As there were thousands of files and it’s tough to copy paste them manually. I got to know that Zendesk offers a rich set of API’s to manage Forum and it’s contents. I have created a Python script to import bunch of offline HTML files into Zendesk Forum creating Topics/articles in a Forum under Categories

We can perform either of the following features in Forum section.

  • List Forums

  • Show Forum

  • Create Forum

  • Update Forum

  • Delete Forum

Example request available in the Zendesk developers page is using curl.

curl https://yoursubdomain.zendesk.com/api/v2/topics.json -H "Content-Type: application/json" -v -u email:password -X POST -d '{"topic": {"forum_id": 79161, "title": "My Topic", "body":"This is some code", "topic_type": "articles", "access": "logged in users" }'

The above example had a limitation of adding HTML code into<code>, which is impossible when we had thousands of files to be uploaded. Thus I wrote a Python script tweaking the above example, so that I can refer an external file to fetch HTML contents and import it as an individual Topic.

Source can be found here..

https://github.com/ijeyanthan/zendesk-import-into-forum

To know more, visit http://developer.zendesk.com/documentation/rest_api/forums.html for the list of possible JSON requests available in Zendesk.