6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Teams版Power Virtual Agents のチャットボットにSVG形式の画像が表示できるのか?

Posted at

はじめに

@h-nagao さんが、Power AppsでSVGを利用した日本地図の都道府県を塗るアプリを作られました。

これをTeams版Power Virtual Agetnsで実装しました。SVGを作成するのはPower Automateです。

が、結論から言いますと、

TeamsチャットボットでのSVG表示は不可能です

よって、代替案を考えてみましたので記載いたします。

注意

本記事を実装するにあたり、プレミアムコネクタを利用するためPower Automateの有償ライセンスが必要となります。

SVGがダメなら表示できる形式に変換すればいい

表題の通り、Power AutomateでSVGをPNGに変換してチャットボットへ返します。

全体像です。

image.png

各アクションの説明

SVG画像データを定義

svgタグから始まるSVGデータを用意してください。

image.png

Cloudmersive API で扱えるJSON形式に変換

入力には下記を記載してください

{
  "$content-type": "image/svg+xml",
  "$content": "@{base64(outputs('作成'))}"
}

image.png

Cloudmersive API でSVG→PNGに変換

画像の形式変換にはCloudmersiveコネクタを利用します。
[Cloudmersive](https://account.cloudmersive.com/)

Signupし、API Keyをコピー取得します。
個人利用であれば「Free Tier」を選択し、追加料金なしで利用可能です。

{5DB2ECAB-E045-4E79-BEA6-90E21F38D16E}.tmp.png

Cloudmersive Image Processingを選択し
image.png

接続名は任意、APIキーには上記で取得したKeyを設定します。
image.png

対象画像ファイルは上記の「Cloudmersive API で扱えるJSON形式に変換」で作成したアクションのOutputを、出力には[任意の名前].pngを指定します。

image.png

チャットボットで表示できるようにHTMLタグを付与

Temas上のチャットボットではタグが解釈可能です。
このアクションの出力をトピックに返し、メッセージに埋め込めばチャットボットで画像が表示されます。

<img src="data:image/png;base64,@{body('入力画像を_PNG_形式に変換する')?['$content']}"> 

image.png

まとめ

SVGはレスポンシブに表示可能で汎用性が高く便利な画像形式です。
が、残念ながらTeamsでの表示は不可のため、今回のような工夫が必要です。活用ください。

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?