Developing an AI-Powered UltraDNS Chatbot for Slack
CompletedClosing out 2024, I wanted to share an experimental project I’ve been working on: creating an AI-powered DNS chatbot for Slack. You can find the repository on GitHub:
https://github.com/vercara/udns_slackbot
This is still in the early stages of development, but it provides a baseline framework for integrating with OpenAI’s (beta) "Assistants" functionality. The idea is to use specialized DNS assistants to analyze data from an UltraDNS account and return actionable insights.
This initial iteration is designed to be extensible, with key functionality modularized into the following classes:
-
AssistantClient: Manages communication with the various assistants that make up the client’s AI backend. To minimize the length of instruction sets, each assistant is specialized for a specific role—for instance, one assistant focuses on general DNS questions, while another is tailored for interpreting DNS health checks. When thread management is integrated in the future, that functionality will also be added here. -
UltraDNSClient: Serves as a wrapper for UltraDNS’s Python client, handling queries to the REST API and, additionally, pulling data from the - page.
-
InferenceClient: Collects data from the UltraDNS client and constructs the prompts to send to the respective assistant for processing.
Additionally, constructing and running the bot involves two primary scripts:
-
initialize.py: If assistants don’t already exist in your OpenAI account, this script creates them the first time the container is run. The initialization script generates assistant IDs and stores them in a file calledconfig.json, which is saved in thedatavolume mounted (by default) directly to your working directory. This setup ensures your assistants persist and avoids creating new ones repeatedly. -
app.py: This script runs the Slack daemon inside the container. It’s where different slash commands and actions are mapped to the bot’s behavior in a Slack channel.
Future functionality
I already have some ideas lined up for the future of this bot.
Better logging
It’s not the most exciting update, but I’m well aware that the bot needs better logging. I plan to enhance the Docker log output with more general and informational messages to make debugging and monitoring easier.
Retaining context
As it stands, every interaction with the bot starts a new, separate thread. I’d like to enhance the bot so you can hold a conversation where it retains the context of your previous messages. For example:
- You ask the assistant to perform a health check on a zone file.
- The assistant responds with suggestions A, B, and C.
- You ask the assistant for more information on how to accomplish suggestion B.
- The assistant provides an expanded explanation for suggestion B.
Currently, to continue a conversation, you need to summarize the bot’s last response in your prompt.
How will this work?
Just like assistants, threads have individual IDs. You can continue a thread by passing the thread ID along with your request. These thread IDs will need to be stored locally—most likely within a SQLite database located in the data volume.
To make this work within Slack, I’m considering using Slack’s ability to reply to specific messages, creating isolated dialogues within a channel. This might require some re-architecting of the current functionality, but the idea is that the identifier of a Slack thread would correlate directly with an OpenAI thread.
Making it smarter
There’s plenty of room to enhance the intelligence of the DNS assistant, and this can be achieved by providing customized grounding data. For example, summaries of DNS RFCs could be made directly available to the assistant through data files.
This will be an ongoing process as we refine the instruction sets and as the base models themselves become more intuitive over time.
Custom prompts
I plan to add a variable to the environment file that allows users to include a custom set of instructions in the prompts. This will support both general instructions that apply universally and assistant-specific instructions for more tailored behavior.
Ollama support and other LLMs
A larger project I have in mind involves expanding the bot’s framework to work with either a locally hosted Ollama instance, the OpenAI API, or both. Ollama opens up exciting possibilities, such as training a specialized, DNS-focused model for use with the application.
In the future, I’d also like to add support for other LLMs, such as Anthopic's Claude, to make the bot even more versatile.
Thoughts
I hope people find this project interesting, and I’d love to hear your input on what functionality you’d find useful in an UltraDNS Slack integration. As always, feel free to fork the repository and create your own custom iterations of this tool—if you do, I’d be excited to see what you come up with, so please share!