Skip to content

Latest commit

 

History

History
119 lines (92 loc) · 5.09 KB

File metadata and controls

119 lines (92 loc) · 5.09 KB

Copilot Studio — Tool Configuration

API Endpoint

POST https://<YOUR-FUNCTION-APP>.azurewebsites.net/api/chart?code=YOUR_API_KEY

Tool Description (paste into the action description in Copilot Studio)

Generates chart images using matplotlib. Returns a public URL to the PNG image. Call this tool when the user asks to create, plot, or visualize a chart or graph from data. Supported types: bar, line, pie, scatter, histogram, area, box, violin, heatmap. Supports single-series and multi-series (except pie and heatmap). After calling, display the URL as an image: ![Chart](url)

Input Variable Instructions

Paste these into the description / instruction field for each input variable.

chart_type (required, string)

Required. One of: "bar", "line", "pie", "scatter", "histogram", "area", "box", "violin", "heatmap". Choose: "bar" for comparing categories, "line" for trends over time, "pie" for proportions, "scatter" for two-variable relationships, "histogram" for the distribution of one variable, "area" for cumulative/filled trends, "box" or "violin" for comparing distributions across groups, "heatmap" for a 2D matrix of values. Example: "show sales by region" -> "bar"; "trend over months" -> "line"; "response-time distribution by server" -> "box"; "correlation matrix" -> "heatmap".

data (required, object)

Required. JSON object with the data to plot. Shape depends on chart_type.
Single-series: Bar/Pie {"labels":["A","B"],"values":[10,20]}. Line/Scatter/Area {"x":[1,2,3],"y":[10,20,30]}. Histogram {"values":[1,2,2,3,3]}. Box/Violin {"values":[[...],[...]],"labels":["A","B"]}. Heatmap {"matrix":[[1,2],[3,4]],"xlabels":["c1","c2"],"ylabels":["r1","r2"]}.
Multi-series (all except pie and heatmap): use "series" array. Bar: {"labels":["Q1","Q2"],"series":[{"name":"North","values":[10,20],"color":"steelblue"},{"name":"South","values":[15,25],"color":"coral"}]}. Line/Scatter/Area: {"series":[{"name":"2024","x":[1,2,3],"y":[10,20,30]},{"name":"2025","x":[1,2,3],"y":[15,25,35]}]}. Box/Violin: {"series":[{"name":"A","values":[1,2,3,4]},{"name":"B","values":[2,3,4,5]}]}. Each series can have "name", "color", and "marker" (line/scatter only).
Error bars (bar/line only): add "yerr" or "xerr" arrays at the series or top level.
Use numbers for values/x/y, strings for labels. Prefer multi-series when comparing groups.

params (optional, object)

Optional. JSON object for styling. All keys optional.
Titles/axes: "title" (always set when possible), "xlabel", "ylabel", "title_fontsize" (default 14), "label_fontsize" (default 12).
Theme/grid: "style" (one of "default","ggplot","seaborn-v0_8","dark_background","fivethirtyeight","bmh","grayscale"), "grid" (bool, default false).
Figure: "figsize_w" (default 8), "figsize_h" (default 6), "dpi" (default 150).
Scale/limits: "xscale"/"yscale" (one of "linear","log","symlog"), "xlim"/"ylim" (2-element arrays like [0,100]).
Color (single-series): "color" (e.g. "steelblue"), "colors" (array for pie slices), "marker" ("o","s","^").
Bar: "orientation" ("v" or "h"), "stacked" (bool), "bar_width" (default 0.8).
Area: "stacked" (bool), "alpha" (default 0.5).
Histogram: "bins" (default 10).
Pie: "autopct" (default "%1.1f%%").
Violin: "show_means" (bool), "show_medians" (bool, default true).
Heatmap: "cmap" (e.g. "viridis","plasma","coolwarm","RdBu_r"), "annotate" (bool).
Example: {"title":"Sales","xlabel":"Quarter","ylabel":"Revenue","style":"ggplot","grid":true,"yscale":"log"}

Output Variable Instructions

url (string)

Public URL to the generated chart PNG image. Display as image: ![Chart](url)

Power Automate Setup (HTTP Action)

  1. Create a flow with trigger "Run a flow from Copilot" (or HTTP request)
  2. Add an HTTP action:
    • Method: POST
    • URI: https://<YOUR-FUNCTION-APP>.azurewebsites.net/api/chart?code=YOUR_API_KEY
    • Headers: Content-Type = application/json
    • Body:
      {
        "chart_type": "@{triggerBody()?['chart_type']}",
        "data": @{triggerBody()?['data']},
        "params": @{triggerBody()?['params']}
      }
  3. Add a Parse JSON action on the HTTP response body:
    {
      "type": "object",
      "properties": {
        "url": { "type": "string" }
      }
    }
  4. Add a Response action returning the parsed url

Copilot Studio Setup

  1. Go to your agent > Actions > + Add an action
  2. Select the Power Automate flow
  3. Paste the tool description above into the action description
  4. For each input variable, paste the matching variable instruction above
  5. Save & publish

Managing API Keys

Each user/agent gets their own API key. Create new keys with:

az functionapp keys set --resource-group <YOUR-RESOURCE-GROUP> --name <YOUR-FUNCTION-APP> --key-name USER_NAME --key-type functionKeys

List all keys:

az functionapp keys list --resource-group <YOUR-RESOURCE-GROUP> --name <YOUR-FUNCTION-APP>

Delete a key:

az functionapp keys delete --resource-group <YOUR-RESOURCE-GROUP> --name <YOUR-FUNCTION-APP> --key-name USER_NAME --key-type functionKeys