Test and debug an API plugin

To test and debug an API plugin for Microsoft Copilot, you can sideload it in Bing using https://www.bing.com/copilot/devtools. This guide shows you how to sideload your own API plugin in Copilot in Bing, and then test it.

Sideloading an API plugin in Copilot in Bing is useful when developing an API plugin, because it allows you to test your API plugin before submitting it to Partner Center to make it available to your users. When you sideload your API plugin in Copilot in Bing, your API plugin is only available to you, and only temporarily. To make your API plugin available to your users, you need to publish it. To learn more, see Publish an API plugin.

Important

These features are in Private Preview.

Manifests that use the auth field are not supported.

Allow Bing to access your API plugin files

Before testing your API plugin in Copilot in Bing, you need to grant Bing access to your API plugin files. By default, the web browser that you use to load your API plugin won't allow access to your API plugin files unless you grant access to the origin that hosts the files.

To allow Bing to access your API plugin files, use CORS. Add the Access-Control-Allow-Origin CORS response header, with its value set to https://www.bing.com, to your web server's responses.

If you followed Get started building an API plugin for Microsoft Copilot, your web server uses the Express NPM package to serve your API plugin files. To add the Access-Control-Allow-Origin CORS header to your web server's responses, use Express' CORS middleware:

  1. In Visual Studio Code, click View > Terminal, or press CTRL + ` to open the Terminal panel.

  2. Type npm install cors and press Enter. The Express CORS middleware package is now installed.

  3. Open the file that contains your Express server code. If you followed the guide, this is server.js.

  4. Import the CORS middleware in the file by adding the following line of code at the top of the file:

    import cors from "cors";
    
  5. Configure the CORS middleware to allow access to your API plugin files, by adding the following line of code after the app variable is defined:

    app.use(cors({ origin: "https://www.bing.com" }));
    
  6. Save the file.

  7. Restart your web server. For example, in the Terminal panel, press Ctrl+C, type node server.js, and then press Enter. The server restarts.

Make your local server accessible to the internet

If you intend to sideload an API plugin that's already deployed to a web server that's accessible from the internet, you can skip this section.

If you're developing a locally hosted API plugin, your API, API specification, and manifest file are only available on your local web server, which means that Copilot in Bing can't access them.

To make your API plugin available to Copilot in Bing, for testing, it needs to be on a server that's accessible from the internet via HTTPS. If you want to continue working on your local device only, make your local web server temporarily available over the internet by using the port forwarding feature of Visual Studio Code. To learn more, see Local Port Forwarding.

To make your local server accessible to Copilot in Bing over the internet:

  1. Make a note of the port number which your web server is using. If you followed Get started building an API plugin for Microsoft Copilot, this is 8080.

  2. In Visual Studio Code, select View > Open view > Ports. The Ports panel appears:

    The Ports panel in VS Code

  3. Click Forward a port, enter 8080 in the Port number or address field, and then press Enter. If your web server is running on a different port number, use the port number that your web server is using.

    The Forwarded address value appears:

    The Ports panel in VS Code, showing the Forwarded address

  4. Right-click the Forwarded address value, and then select Port visibility > Public.

  5. Under Forwarded address, click the Copy local address (The copy local address icon) button.

  6. Open the openapi.yaml file.

  7. In the file, change the servers.url field from http://localhost:8080 to the address you just copied. The copied address should be patterned like: https://ab12c3de-8080.uks1.devtunnels.ms/

  8. Save the file.

Sideload your API plugin in Copilot in Bing

To sideload your API plugin in Copilot in Bing:

  1. Open a new tab or window in Microsoft Edge and go to https://www.bing.com/copilot/devtools.

  2. Sign-in to Copilot with your personal Microsoft account (MSA). Microsoft Entra ID accounts aren't supported.

  3. In the sidebar, click Plugins. The list of installed plugins is displayed.

  4. Click the Test a plugin (The Test a plugin button icon) button:

    The plugin test sidebar in Copilot in Bing

    The Enter plugin URL dialog opens.

  5. Enter the URL of the web server that hosts your API plugin files. If your web server is on your local device, make it accessible to the internet by using port forwarding. See Make your local server accessible to the internet.

    The Enter plugin URL dialog in Copilot in Bing

  6. Click the Find manifest file button. The Found plugin dialog opens and displays validation information about your API plugin:

    The Found plugin dialog, showing the new API plugin and the Add plugin button

    • If your API plugin was validated successfully, the API plugin title and description is displayed, and the Add plugin button appears.
    • If Copilot in Bing found errors while validating your API plugin, the errors are listed in the dialog. Review the errors, correct them, and start again.
  7. Click the Add plugin button. Copilot displays your new API plugin.

Test your API plugin in Copilot

To test your API plugin:

  1. In the Plugins sidebar, turn on the toggle next to your API plugin, to enable it:

    The Plugins sidebar, showing the new sideloaded API plugin, and the enable button next to it

  2. In the chat user interface, click the New topic button, and click the More Creative conversation style. API plugin sideloading is currently supported in Creative and Precise conversation styles.

    The Bing Chat UI, displaying a new, empty, conversation

  3. In the Ask me anything text field, type a message, and then press Enter. Copilot in Bing displays a response. Depending on your question, Copilot might use your sideloaded API plugin to generate the response:

    The Bing Chat UI, displaying a response from Copilot in Bing

See also