Example 3 - Use Bing Search as a fallback in Microsoft Copilot Studio

Important

Power Virtual Agents capabilities and features are now part of Microsoft Copilot Studio following significant investments in generative AI and enhanced integrations across Microsoft Copilot.

Some articles and screenshots may refer to Power Virtual Agents while we update documentation and training content.

Note

Microsoft Copilot Studio now supports these features without Composer.

Enhance your bot by developing custom dialogs with Bot Framework Composer and then adding them to your Microsoft Copilot Studio bot.

In this example, you'll learn how to set Bing search as a fallback answer in Microsoft Copilot Studio by using Composer.

Important

Composer integration isn't available to users who only have the Teams Microsoft Copilot Studio license. You must have a trial or full Microsoft Copilot Studio license.

Prerequisites

Create a fallback trigger

  1. In Microsoft Copilot Studio, open the bot from Example 2. If you haven't completed Example 2 yet, see Display a multi-select options list in Microsoft Copilot Studio.

  2. Open your bot in Composer. For instructions on how to do so, see Getting started with Bot Framework Composer.

  3. In the bot explorer, go to the main dialog. Select More options (...) then select Add new trigger.

  4. In the Create a trigger window, for What is the type of this trigger?, select Unknown intent. Select Submit.

    Screenshot of the Create a trigger window.

  5. Go to the Bot Responses page, select Contoso Meal Delivery Service, then select Show code.

  6. Copy and paste the following into the code view:

    # adaptivecardjson_BingSearch(user_utterance)
    - ```
    {    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "type": "AdaptiveCard",
        "version": "1.2",
        "fallbackText": "This card requires Media to be viewed. Ask your platform to update to Adaptive Cards v1.1 for this and more!",
        "actions": [
            {
                "type": "Action.OpenUrl",
                "title": "Search with Bing",
                "url": "https://www.bing.com/search?q=${user_utterance}",
                "style": "positive"
            }
        ],
        "body": [
            {
                "type": "Image",
                "url": "https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RWe65Z?ver=2d4e&q=90&m=6&h=201&w=358&b=%23FFFFFFFF&l=f&o=t&aim=true"
            },
            {
                "type": "TextBlock",
                "text": "${user_utterance}",
                "wrap": true,
                "separator": true,
                "horizontalAlignment": "Center",
                "size": "Medium"
    
            }
        ]
    }
    ```
    

    Screenshot of the Adaptive Card JSON added to bot responses.

  7. Copy and paste the following code into the same code view:

    # AdaptiveCardBingSearch(user_utterance)
    [Activity
        Attachments = ${json(adaptivecardjson_BingSearch(user_utterance))}
    ]
    
    

    Screenshot of the activity added to the bot responses.

  8. Go to the Create page. In the main dialog, select the Unknown intent trigger.

  9. On the authoring canvas, select Add (+) then Send a response.

  10. In the properties pane, under Bot responses, and select Show code.

    Warning

    Adding the expression in the next step to the response editor instead of the code editor will result in the bot responding with raw JSON instead of an Adaptive Card.

  11. Copy and paste the following expression:

    - ${AdaptiveCardBingSearch(turn.activity.text)}
    

    Screenshot of the response for the send a response action.

Test your bot

  1. Publish your Composer content to make it available in your Microsoft Copilot Studio bot.

    Important

    Selecting Publish in Composer makes the changes available for testing, but doesn't automatically publish your bot.

    Publish your bot in Microsoft Copilot Studio to update your bot across all the channels it's connected to.

  2. Go to the Microsoft Copilot Studio Topics page to see your new OnUnknownIntent topic.

    Screenshot of the new topic visible in Microsoft Copilot Studio.

  3. Open the Test bot pane and make sure Track between topics is turned on. Enter the message Is tofu vegan? to start your conversation.

    Screenshot of the Microsoft Copilot Studio test bot pane.

Next Steps

Example 4 - Display a form with a Submit button in Microsoft Copilot Studio.