Friday, October 20, 2023

Adding Input Parameters to Microsoft Power Virtual Agents Topics

Prompt (Expand to see prompt used)
# I thought the introduction could use more explanation of how input parameters are normally created, so here's my additional prompt
Prompt (Expand to see prompt used)

Introducing Input Parameters in PowerVirtualAgents: Beyond the Usual Route

In the world of Power Virtual Agents, creating a seamless flow for data between various topics is both an art and a science. The conventional wisdom is to employ a question node to set up an input parameter. By designating the variable to "Receive values from other topics", we can ensure the topic procures the necessary information, even directly from the user when the parameter isn't specified. It's an intuitive approach, particularly when the parameter is imperative for the conversation to progress.

However, this brings us to an interesting quandary: What happens when we're content with a default value, specifically the Blank()? What if the input parameter isn't always mandatory and we want to circumvent that additional user prompt? The answer lies in an alternative, nuanced approach that we're delving into today.

Join us as we navigate the subtleties of Power Virtual Agents, and discover how to enhance our bot's flexibility without overburdening the user.


Input parameters are a useful feature in Microsoft Power Virtual Agents that allow you to pass data when calling topics from other topics. It provides more flexibility and dynamism in shaping user experiences. Today, we'll guide you through the process of adding these parameters via YAML file editing.

Setting up a Topic with Input Parameters:

Here's how you can set it up:

  1. Create a New Blank Topic: Begin by initiating a new topic.

  2. Change Trigger Type to Redirect: Instead of the default trigger type, opt for the 'redirect' type. This allows your topic to be initiated from another topic, passing in any necessary data.

    # A Topic doesn't need to be explicitly setup with a redirect trigger in order to be called from another topic, it just ensures that the topic isn't accidentally called form a trigger phrase. Additionally you can declare input parameters on any trigger, I think, haven't tried all trigger types yet.

  3. Open Code Editor for YAML: Access the YAML editor in Power Virtual Agents to manually edit the topic definition.

  4. Paste the Example YAML into Editor:

  5. Close the Code Editor: Once you've added your input parameter, save and close the editor.

  6. Add Conditions Based on the New Input Parameter: Now, you can set conditions in your topic that react differently depending on the value of DisplayOutput.

PVA Variables window after adding Input parameter

The final YAML structure should resemble:

Calling Your New Topic with Input Parameters:


After setting up a topic with input parameters, you can call it from another topic. Here’s how:

  1. Create a New Topic: Start by creating a new topic from which you’ll call your redirect topic.

  2. Add a Trigger Phrase: Add a phrase which, when uttered by a user, will trigger this topic.

  3. Add a New Node to Redirect: Add a node in your flow that redirects to the topic with the input parameter.

  4. Click on "Add Input" and Select Your Input Parameter: From the options, select 'DisplayOutput'.

  5. Provide the Value to Pass to the Input Parameter: For our example, we’ll pass a value of 'false' to the 'DisplayOutput' parameter.

The YAML for this calling structure will look something like:

That's it! You've now successfully added input parameters to a Power Virtual Agents topic via YAML editing and called it from another topic. This provides a robust way to manage inter-topic data flow and make your bots even more interactive.

# Forgot to instruct the AI to create a section to see the bot in action, so here we go

Prompt (Expand to see prompt used)

The Bot in Action: Visualizing the Input Parameter Difference

Having dived deep into the nuts and bolts of Power Virtual Agents, the real charm is in witnessing the subtle yet impactful differences in the user experience. Let's see how the bot behaves differently based on our input parameters.

Scenario: We've set up two distinct triggers to test our bot's response based on the DisplayOutput parameter.

  1. Testing "Redirect with Output"

    User Interaction: The user types in, "Test redirect with output."

    Bot's Response:

    Hello from RedirectTopic
    

    Here, our bot provides feedback upon redirection. The DisplayOutput parameter is presumably set to 'true', prompting the bot to display the message.

  2. Testing "Silent Redirect"

    User Interaction: The user enters, "Test silent redirect."

    Bot's Response:

    [No message displayed]
    

    In this interaction, the bot stays silent after redirection. This indicates that our DisplayOutput parameter is set to 'false', instructing the bot not to display any message post-redirect.


Analyzing the Outcomes:

This real-time experiment showcases the agility of our bot, driven by input parameters. While the distinction might seem minor, it has profound implications for user experience:

  • User Clarity: The explicit "Hello from RedirectTopic" message can be reassuring for users, indicating that the bot has processed their request.
  • Efficiency: The silent redirect, on the other hand, is swift and efficient, especially for tasks that need no extraneous feedback.

Engaging with the bot using these two triggers vividly brings out the underlying mechanism we've set up. It's a testament to how fine-tuned control over bot responses can lead to varied and tailored user experiences.


In essence, this hands-on interaction underlines the beauty of Power Virtual Agents: the platform’s capability to cater to diverse user needs, all governed by a simple parameter change in the background.

No comments: