25 Nov 2024
Custom GPTs + APS
In November 2023, OpenAI announced custom GPTs, and if you're like me, one of your first thoughts was: "can I create a custom GPT that will talk to Autodesk Platform Services?", and the answer is yes, you can! In this blog post we'll build a simple GPT that will use the Issues API to answer questions about issues in our Autodesk Construction Cloud projects.
Prerequisites
On the ChatGPT side, it's important to mention that the creation of custom GPTs requires a paid subscription. Please see the pricing section for more details.
On the APS side, you'll need to have an existing APS application with provisioned access to Autodesk Construction Cloud. If you're not sure about these, please refer to our tutorials:
Create Custom GPT
Let's start by creating our custom GPT. After logging into ChatGPT, head over to https://chatgpt.com/gpts, and hit the Create button in the top-right corner.
Next, specify the name and description for your GPT, and consider adding some of the additional settings:
- Instructions are used to specify additional instructions as to how the GPT should answer questions in the future (I used "You are an AI assistant helping with questions about project data in Autodesk Construction Cloud")
- Conversation starters is where you can provide some examples of questions you can ask (I used "List all issues in project 13d04922-07f0-4b04-b7e3-988ec68fc6e8" and "What types of issues can I create?")
- Knowledge let's you upload documents that the GPT will use when answering your questions
- Capabilities is where you can enable additional "behavior" for your custom GPT (I enabled "Code Interpreter & Data Analysis", allowing the large language model to generate Python scripts in order to calculate all kinds of analytics)
Now comes the important part - Actions. These are basically REST API endpoints - described using OpenAPI schema - that the custom GPT can call when you chat with it. Our platform doesn't currently provide OpenAPI specs for the individual services (not yet at least) but you could potentially reverse-engineer them from the documentation. Here's a simplified OpenAPI specification describing the GET issues and GET issue-types endpoints that we will use in this blog post: https://gist.github.com/petrbroz/a4274548c52e2ee71914c9e644490e5e.
While still in the custom GPT configuration panel, hit the Create new action button in the bottom-left corner to enter the Add actions panel which should look like this:
Click the gear icon next to the Authentication input, choose OAuth as the authentication type, and enter the following details:
- Client ID - your APS application client ID
- Client Secret - your APS application client secret
- Authorization URL - https://developer.api.autodesk.com/authentication/v2/authorize
- Token URL - https://developer.api.autodesk.com/authentication/v2/token
- Scope - data:read
Finally, hit Save to return to the Add actions panel. Copy the OpenAPI specification from earlier (gist) into the Schema field, and in a moment you should see 3 actions extracted from the YAML: getIssueTypes, getIssues, and getIssueDetails:
You can now leave the actions panel using the "<" button to the left of the Add actions title.
One final thing we need to do is take the Callback URL that was generated for us by ChatGPT (it should look something like https://chat.openai.com/aip/g-...), and register it for our APS application on https://aps.autodesk.com/myapps:
And with that, our custom GPT is now ready to use!
Test Custom GPT
All 3 actions that we've configured require some kind of a project (or rather, an issue container) ID that the custom GPT doesn't know about, so to keep things simple for our experiment, let's just grab this ID directly from ACC. Navigate to one of your ACC projects, head over to the Issues section, and grab the ID from the URL address:
And now you can finally start chatting with your custom GPT! For example, try kicking things off with some of the following prompts:
- "Give me a visual report of all issues in project <your issue container ID>"
- "I've found a hole in the ground on the 2nd floor. What type of issue should I report?"
If this is the first time you're asking your custom GPT a question, you'll be prompted to log in with your Autodesk credentials, and then, whenever the GPT decides to make a call to one of the configured REST API endpoints, it'll ask for consent. You experience should then look something like this: