There are not many new technologies that come out that make you think they can change the world we live in but ChatGPT definitely feels like that for me. This new model from OpenAI is catching lots of buzz and its capabilities are impressive to say the least. I have personally been using the underlying technology to help me write code with GitHub copilot and it has speed up my development and overall learning tenfold. ChatGPT caught my attention immediately because of its ability to answer almost any question. My MSP mind went straight to leveraging that from a support perspective since it could lead to a ton of self-help. For that reason, I performed a POC where I developed a custom Teams app that acts as support hub. The app integrates with the OpenAI API for text completion to answer questions and I also integrated it with our PSA tool to show the user their open tickets as well as giving them the ability to create a new ticket. In this article, I will be breaking out how I accomplished the POC.

The Solution

TLDR

  • I acquired an Open AI API Key
  • I built a custom Teams App from a sample that leverages React and Javascript
  • I make API calls to the Open AI API when a user asks a question
  • I leverage a React library to grab the users profile info from Teams so that I can look them up in our PSA tool to get all of their active tickets
  • I leverage the same profile to tie them to a ticket when they submit a new case

OpenAI

Leverage the OpenAI API documentation to review the available endpoints. In this example, I am using the completions API to make a POST request when a user submits a question.

Here you can define the body which includes the model, the prompt (what the user types in), the temperature, and the max tokens.

The QuickStart tutorial section provides a sample that I thought was very valuable to grasp the API and what it is doing under the hood.

Custom Teams App

You may already know how to build and deploy a Teams app but Microsoft provides sample tutorial apps here: Get started – Overview – Teams | Microsoft Learn

You can leverage the Teams app with Javascript and React to replicate what I made here.

PSA Integration

The PSA integration I built simply leverages the PSA tool’s API. In this case I just used Syncro because that is what we use for ticketing currently, but it can be replicated across all the platforms that have an API like ConnectWise, AT, BMS, etc. I am leveraging the microsoft/teams-js library to pull in the user profile information of the currently signed in user. From here I can use their UPN to lookup their contact ID in the PSA tool and make a subsequent call to get all of their open tickets. I am doing the same when they submit a new ticket.

Insights

The OpenAI API takes in parameter called temperature. Higher values here means the model will take more risks when trying to derive an answer. I had this set to .06 but when I shifted it to 1 the answers where sometimes more accurate. .06 had more consistency to the answers but were not always as accurate as I would have liked to see. Having this set to 1 definitely led to some wild answers sometimes as well.

You can also designate the maxToken value for a request. I am not going to get into the specifics here but the tokens relate to the amount of words that are submitted in a prompt. The more words, the more tokens used. If you do not provide enough tokens, the response you get will be truncated.

So why wouldn’t you just bump the maxToken quantity to the highest possible value? Well tokens are tied to pricing as you can see below:

In our example we are using the Davinci model which is 2 cents per 1k tokens. This may not seem like a much but as you can see in the example this could add up quickly. Cost could quickly become a major concern if users are blowing up the chat all of the time.

Final Thoughts

There are tons of applications that this technology could be used for within an MSP. I highly encourage you to check it out if you have not already.

If you want to check out the code I wrote for this app, I have it up on my GitHub today: msp4msps/OpenAI_MSTeams: Custom Teams app that uses OpenAI API and integration to PSA Tool (github.com)

Share with the Community