Blog Post

Developer Blog
5 MIN READ

A Python Library for Khoros Community

SuzieH's avatar
SuzieH
Khoros Alumni (Retired)
3 years ago

Photo by Hitesh Choudhary on Unsplash


One of my favorite things about working at Khoros and writing about our products is that I get to witness the Khoros mission play out in real-life situations. This happens often in chat experiences I know are powered by Modern Chat and the Khoros Automation Framework, and I also see it in brand outreach via social media. But one of the most rewarding examples is when I see something exemplifying the power of Community – connecting, helping, and sharing with the intention of making life easier. Community is more than a product. It's a mindset.

Today we're highlighting a contribution by a developer who embodies the Community spirit. He built an open-source Python SDK for Khoros Community and we want to share it with other Community customers. Other developers working with Khoros Community have already contributed to his project.

I got a chance to chat with this developer over Zoom to learn more about his Khoros journey and the Python library.

Note: The Python library discussed in this article is not part of Khoros's official Community platform, has not been tested by Khoros, and is not supported by Khoros.

Q&A

What does the Python library provide?

I've tried to keep the library flexible to support different work patterns. I built it to be as generic or detailed as a user needs it to be. For example, you could use the khoros.messages.create function to create a message or simply use khoros.get if you just want a shortcut for a GET request.

At a high level, the project package is comprised of Primary modules, including the Core object and module and Supporting modules.

The Core object/module object is your hub. You'll Instantiate the Core object by passing Khoros credentials. The Core module is a collection of core functions and tools to work with the Khoros Community APIs.

Other Primary modules:

  • handle interactions with the Community REST APIs
  • facilitate authenticating to Khoros Community environments
  • enable API queries using the LiQL syntax
  • provide functions to work with various Community API objects and structures (e.g. community, categories, nodes, and tenants)
  • facilitate working with SAML assertions
  • retrieve Community Plugin SDK details (SDK and dependency versions, installation state)

The library's Supporting modules:

  • contain classes supporting error and exceptions handling
  • provide tools and utilities like dictionary conversion, timestamp formatting, and environment variable retrieval/update
  • help with their Community Plugin SDK set up and publishing
  • support helper file import and parsing to facilitate ease of use and configuration setting for the package
  • perform unit testing

What are some of the more popular modules?

Probably the Objects module. The functions to create and update users and roles are heavily used. Publishing messages on behalf of other users also gets a lot of use.

Other functions simplify cumbersome processes like creating a message with attachments. I thanked my past self for writing that when we migrated legacy intranet content to the community.

I find that developers new to the Community REST API struggle a bit with API v1. The V1 subclass provides methods for performing base v1 requests.

What have you and your team been able to accomplish with the SDK?

The Objects module enabled a lot of automation and migration tasks like moving posts out of one system and into Community.

When we migrated to Khoros, we used our library to create our new Community Structure – over 200 nodes. We were able to put the community structure into a CSV file, ingest that with the SDK and let the library create our node structure for us. It saved us a ton of time.

Also, we publish security advisories in the community. Generally, these are legally-mandated advisories of security vulnerabilities and other important issues. We've used the SDK to auto-subscribe customers to notifications in various group hubs so that they receive the announcements automatically. Community didn't support the functionality we needed out-of-the-box, so we built it.

We publish advisories via the API under a pseudo-account (like Product Manager) when we publish advisories. We do this to avoid a single employee from being bombarded with DMs simply because they published an article. Again, the SDK helps us automate that process.

Where do the library and SDK fit into your day-to-day programming work?

We have 9 people on our Community development team. We have back-end and front-end developers across the globe who use the SDK daily to complete their tasks maintaining and improving the site. We've also used the SDK to build automation tools for other groups. We built a documentation integration with MadCap Flare. The Dev team built a tool where they can export content from MadCap, push it to a Github repo, and use a homegrown administration panel that enables the writers to publish the content to Community.

Basically, Python scripts parse the content to make it compatible with Khoros Community and use the API (via my Khoros package) to systematically publish the content on our community and dynamically construct a Table of Contents component.

I see additions in the changelog from folks outside of your organization. It looks like other people are starting to discover it. When did you begin to get traction with regard to open source?

I added a post to Dev Forum about the SDK earlier this year. That drove some people to it. I've been building functionality and added updates most months since I launched it. One developer reached out through Atlas about LithiumSSO. That person and I collaborated and got the code included (including documentation). It's been a great way to connect with other Khoros customers. I can see the downloads from the Python Package Index (PyPI). It feels great to receive enhancement requests and pull requests.

Since you mentioned documentation, may I geek out momentarily with a writer question? Your Python library is nicely documented. How did you find Read the Docs for documentation?

So, I'm a Humble Bundle fan. They had a special on Python books at one point that included a book called Serious Python. That book turned us on to Sphinx (a documentation generator) and then Sphinx brought us to Read the Docs. It pulls documentation right out of the code comments. It's been really convenient and it was straightforward to set up.

How do items get on your Roadmap?

I use the Issues section in the Github project as a baby JIRA to collect bug, code enhancement, and doc enhancement requests. I get a few each month and pick them up as I can – or else I brainstorm for cool things to add when I've got some spare time.

Final thoughts

Thank you so much for building this and for talking with us today!

Follow the links below to view the library project and documentation. Check it out, give it a try, and maybe even contribute some code of your own. Happy coding!

Python Library Documentation
Python Library on PyPI
Python Library Github repository

 

 

 

 

 

Updated 3 years ago
Version 2.0
No CommentsBe the first to comment