Use a custom connector from a flow

Note

This article is part of a tutorial series on creating and using custom connectors in Azure Logic Apps, Microsoft Power Automate, Microsoft Power Apps, and calling connectors as tools in Microsoft Copilot Studio. To understand the process, read the custom connector overview. Go to Use connectors in Copilot Studio to learn how connectors are essential tools that greatly extend the functionality of agents.

In this article, you build a basic flow that uses the custom connector you created in a previous article. The flow triggers when you add an item to a SharePoint list. Then the flow uses the custom connector to call the Cognitive Services Text Analytics API. The connector returns the sentiment score (0 to 1) for the text in the list item, and the flow writes the score back to the list. The following image shows the finished flow:

Screenshot of the finished sentiment analysis flow.

Prerequisites

Create the SharePoint list

First, create a simple three-column list in SharePoint Online. This list stores movie review data that the flow analyzes for sentiment. For more information about SharePoint lists, see Introduction to lists in the SharePoint documentation.

  1. In your SharePoint Online site, choose New, and then choose List.

    Screenshot of the SharePoint site New menu with the List option highlighted.

  2. Enter the name Movie Reviews, and then choose Create.

    Screenshot of specifying a name for the new list.

    The list is created, with the default Title field.

    Screenshot of the new list with the default Title field.

  3. Select to add a new item, and then choose Single line of text.

    Screenshot of adding a single line of text column.

  4. Enter the name Review, and then choose Save.

  5. Repeat steps 3 and 4 to add another column to the list. Use a data type of Number, and name the column Score.

Create a flow from the list

SharePoint Online provides the ability to create flows right from a list, so use that approach. You could create the same flow from flow.microsoft.com.

  1. In the SharePoint list, choose Flow then Create a flow.

    Screenshot of the Create a flow option in the SharePoint list.

  2. In the right pane, choose Show more.

    Screenshot of the Show more option in the right pane.

  3. Choose the template When a new item is added in SharePoint, complete a custom action.

    Screenshot of the SharePoint custom action template.

    The custom action in this case is calling the API through the custom connector.

  4. Ensure you're signed in to SharePoint with the correct account, then choose Continue.

    Screenshot of the SharePoint connector permissions.

  5. In flow.microsoft.com, choose Edit. You should see the SharePoint site and list from which you launched the Create a flow process.

    Screenshot of confirming the SharePoint site and list.

Add the custom connector

Power Automate creates a basic flow with a trigger that fires when you add an item to the SharePoint list. Now, add actions to take based on the item that you add.

  1. Select New step, and then select Add an action.

  2. Search for the connector you created, and then select the action associated with that connector.

    Screenshot of choosing the SentimentDemo action.

    The name and description for the action come from information you provide when you create the connector.

  3. Enter values for all the fields.

    Screenshot of the custom connector parameters.

    Parameter Value
    Language "en"
    ID "1"
    Text The SharePoint Review field (from the Dynamic content dialog box)

    You need to provide ID because the connector can handle multiple documents. In these examples, you send one document at a time. In a production flow, Language and ID values might come from a list or another data source.

  4. Select New step and then Add an action.

  5. Add the action SharePoint - Update item and enter values for all the fields.

    Screenshot of the SharePoint Update item action.

    Parameter Value
    Site Address The address of the SharePoint Online site from which you launched the Create a flow process
    List name The list from which you launched the Create a flow process
    Id The SharePoint ID field
    Title The SharePoint Title field
    Review The SharePoint Review field
    Score The custom connector score field

    When you add the dynamic content for the Score field, notice that Power Automate adds an Apply to each container because it recognizes that the custom connector accepts multiple documents. The flow sends one document at a time, but the Apply to each container matches the custom connector's support for multiple documents.

    Screenshot of the Apply to each container.

    The finished flow should now look like the following image:

    Screenshot of the finished sentiment analysis flow.

  6. Enter a name for your flow, like Sentiment Analysis, and then select Create flow and Done.

Test the flow

Now that the flow is complete, test it by adding reviews to the SharePoint list, and see how the flow responds.

  1. In your SharePoint Online list, choose Quick Edit.

    Screenshot of the Quick Edit option in the SharePoint list.

  2. Add two reviews to the list (one negative and one positive), and then choose Done.

    Screenshot of reviews added in Quick Edit mode.

    Parameter Suggested value
    Title (positive) My Favorite Movie
    Review (positive) "I enjoyed the new movie after a long day"
    Title (negative) Some Other Movie
    Review (negative) "The worst movie I've seen in decades"
  3. In flow.microsoft.com, choose My flows, and then choose the flow you created.

    Screenshot of choosing the new flow in My flows.

  4. Look at RUN HISTORY, and you should see two runs—one for each review you added to the list.

    Screenshot of the flow run history.

  5. Back on the SharePoint list page, refresh the browser to see the scores that the flow added.

    Screenshot of sentiment scores added to the SharePoint list by the flow.

You're all done! This is a simple flow, but it gains powerful functionality by being able to call Cognitive Services through a custom connector.

Next steps

To enable people outside your organization to use the connector, share the connector within your organization and get the connector certified:

Provide feedback

We greatly appreciate feedback on issues with our connector platform, or new feature ideas. To provide feedback, go to Submit issues or get help with connectors and select your feedback type.