Power Platform – Custom Connector

 In Power Platform, a custom connector is a tool that allows you to create a connection between your app and an external service or system. With a custom connector, you can extend the functionality of Power Apps by integrating with APIs and services that are not natively supported.

Create a custom connector that is tailored to our specific needs and requirements as follows:

Navigate to the Power Apps portal and select “Custom connectors” from the left-hand menu, then Click on the “New custom connector” button to create a new connector.

Step 1: Under General tab

Fill in the basic information about your connector, such as the name, description, and logo – in the Host textbox, enter: api.openai.com

Article content


Step 2: Under Security tab

Fill as follows:

Article content


Step 3: Under Definition tab

3.1 Click on New action – Define the actions and triggers that your connector will support. An action is an operation that your connector can perform, such as creating a new record or updating an existing one. A trigger is an event that your connector can respond to, such as when a new record is created or updated.

Article content


3.2 Click on Request and fill as follows (as per the OpenAI Documentation), then click Import

API Reference – OpenAI API

Verb: POST

URL: https://api.openai.com/v1/completions

Headers: Content-Type: application/json

Body: { “model”: “gpt-3.5-turbo”, “messages”: [{“role”: “”, “content”: “”}]}


3.3 Click on Import

Article content


3.4 Request then edit the Content-type property then provide a default value and make it required and internal (see capture)

Article content
Article content


3.5 Request then edit the Body property then make it required and important (see capture)

repeat the same for Body payload property (see in green) – content, role, model – edit each of them and make it required and important.

Article content
Article content


3.6 Skip the Code (Preview) tab.


Step 4: Under Test tab

4.1 Click New connection, add your API Key which you created (see above) in the following format: Bearer sk… then click Create

Then fill as follows and click on Test operation

Article content


4.2 Copy the Response Body and set it as a Default Response in the Definition (see next step)

Article content


5.3 Under Definition tab, click Add default Response and paste the Body Response then click Import, then Update the custom connector.

Article content


In conclusion, creating a custom connector in Power Platform enables you to extend the functionality of your Power Apps by integrating with external services like the OpenAI API. By following the steps outlined in this guide, you can set up a custom connector tailored to your specific needs, allowing you to leverage powerful external APIs within your apps. Stay tuned for our next article, where we will delve into how to integrate this custom connector with Power Apps for even greater capabilities and flexibility.

Comments