Saturday, October 21, 2023

Exploring Power Virtual Agents' New (Preview) Feature: The Send HTTP Request Node

Prompt (Expand to see prompt used)

Microsoft's Power Virtual Agents (PVA) is consistently bringing forward new tools and features to empower bot developers. The latest addition, still in preview, is the "Send HTTP request" node. In the past, developers had to rely on PowerAutomate to make these HTTP requests, but this new feature simplifies the entire process. Here's an exploration into the feature, along with a couple of challenges I faced and their solutions.

Setting Up the Send HTTP Request Node

To integrate this new node, follow the steps below:

  1. Inserting the Node: Begin by clicking on the plus icon within your PVA canvas.
  2. Navigating to the Feature: Click on "Advanced" and select the "Send HTTP request" option.
  3. Configuring the Node:
    • URL: Specify the URL endpoint you want to communicate with.
    • HTTP Action: Choose the appropriate HTTP action (GET, POST, etc.).
    • Response Type and Variable Name: Define the response type (JSON, String, etc.) and assign a variable name for the response data.
    • HTTP Headers and Body Value: Add any required headers. If your request needs a body, especially for POST, PUT, etc., fill it in appropriately.
    • Error Handling: Choose between "raise on error" (which stops the bot) or "continue on error".

PVA Simple HTTP Get

Challenges and Solutions

Unexpected JSON Encoding

One peculiar issue I encountered was when attempting to POST an HTTP request using straight JSON as the body. The HTTP serializer they seem to be using (possibly the System.Text.Json.JsonSerializer.Serializer) treated the JSON output as a string, converting special characters like " to Unicode \u0022 and ' to Unicode \u0027. This causes hiccups if the receiving endpoint can't decode these Unicode characters properly.

PVA - HTTP POST with JSON content

Beeceptor.com HTTP capture

Solution: To workaround this, you can do one of the following:

  • Change the type from JSON to Formula
PVA - HTTP POST with JSON content editing formula

Beeceptor.com HTTP capture
  • Change the Body option from "JSON content" to "RAW content" and set the content type as 'application/json'.
PVA - HTTP POST with Raw content

Beeceptor.com HTTP capture

# Didn't like the original text comparing the results, had ChatGPT rewrite

Prompt (Expand to see prompt used)
When testing the adjustments and dispatching requests to Beeceptor.com, the effects on the request body were clear:

  • Utilizing the default "JSON content" option led to the encoding of special characters.
  • On the other hand, two solutions surfaced:
    1. Switching to "RAW content" preserved the original JSON structure without any undesired encoding.
    2. Keeping "JSON content" but using a formula also prevented the encoding issues.

Misleading Error with Incorrect Response Type

Another stumble was setting the Response data type. Initially, I had it set to String, even though the actual response was a JSON object. I presumed it'd simply store the entire body into the string. To my surprise, this setup caused the bot to reply with "Sorry, something went wrong. Error code: SystemError"—not very elucidating.

Solution: After some head-scratching, I tried the "from sample data" feature to set the response type. Lo and behold, the bot sprang back to action, functioning seamlessly.

Concluding Thoughts

The Send HTTP request node is a significant leap towards more streamlined bot-building in PVA. By removing the dependency on PowerAutomate for HTTP actions, this feature adds another layer of versatility and convenience. As with any new feature, there are growing pains, but solutions aren't far behind. Keep an eye out for more of our blogs diving deeper into PVA's evolving landscape.


This feature is in preview, so functionalities and behaviors may change over time.

No comments: