A Quick Guide for Building your own GitHub Copilot Extension
You can build your own Copilot extensions now! It’s really, really fun to be able to chat with Copilot with your own prompts and APIs, and have full integration with your codebases, as well.
There’s a few things you’ll need to do to get this working:
- Register a new GitHub App
- Clone an existing example app locally
- Set up the Copilot settings for your app
- Follow your dreams
Register a new GitHub App
To make a new GitHub App, head to your Developer Settings and hit “New GitHub App”.
You can name it anything you want (but it should be unique), and you can change any of these settings later. Under your Homepage URL and your Callback URL, for now, you can just put https://example.com
, or any other website you want to use. If you don’t have something in the Callback URL, it won’t work!
Now from here, make sure you uncheck “Active” under Webhook.
And finally, under Permissions, go to “Account permissions” and set Copilot Chat to “Read-only” access!
Blammo, that’s all you need for this now. You might want to make your extension only installable on your account right now, but again, you can change that later.
Clone an existing example app locally
Now, keep that Settings tab open, but open VS Code and clone the Blackbeard Extension to your machine!
Make sure you open your Terminal from inside of VS Code for this next part:
- Run
npm install
and thennpm start
. You should have a local server now running atlocalhost:3000
. - In the “Ports” tab, click “Add Port” and plop in
3000
. This will give you a Forwarded Address that we’ll need to use later! - Right click that Forwarded Address, and set “Port Visibility” to “Public” (this is very important, otherwise you won’t be able to test your extension).
- Now right click it again, copy that URL, and let’s go back to your browser.
Set up Copilot settings for your app
With your GitHub App settings open in the tab from earlier, click “Copilot” in the menu on the left-hand side.
Set your App Type to “Agent”.
Put your URL that you have copied in the URL field.
Your description can be anything, and you don’t need a Pre-authorization URL at this point!
Follow your dreams
You’re all set now to test out your extension! You can open up GitHub Copilot chat in VS Code directly, or on GitHub.com.
To talk specifically to your bot, start a message with @
and then your app name, and it should appear in the autocomplete. Chances are Your App Name
will be @your-app-name
.
Now ask it some questions and get a pirate-y response! You can now adjust the existing prompt in the project’s index.js
to your heart’s content, add whatever API calls and scripts you want to add additional functionality, and make your Copilot experience better than ever.
If for some reason you are getting a server error, try restarting your server, and recreating your forwarded URL! It’s rare, but it does happen and a quick reboot + recreation will do the trick.
Until next time!