2
votes

I am using the Bot framework to create a chat bot. And I want to create message card (Hero or Thumbnail).

If you look at the skype bot api doc, there is a way to encode image bytes directly as the content url. https://docs.botframework.com/en-us/skype/chat/

"type": "message/image",
"attachments": [
    {
        "contentUrl": "<base64 encoded image>",
        "thumbnailUrl": "<base64 encoded thumbnail>",          // optional
        "filename": "bear.jpg"                                 // optional
    }
]

This works fine for showing an image only. But I want the image to be part of a card.

The card is

{
"type":"message/card.carousel",
"attachments":[
    {
    "contentType":"application/vnd.microsoft.card.hero",
    "content":{
        "images":[
        {
            "image":"https://foo.com/path/image.jpg",
        }

I have tried to set the image url property to the encoded bytes, but the client can't show it. What's the best way to achieve this?

1

1 Answers

0
votes

You've got the basic idea. Use this instead:

  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.hero",
      "content": {
        "title": "Title",
        "subtitle": "SubTitle",
        "text": "Text",
        "images": [
          {
            "url": "image/jpeg;base64,{YOUR IMAGE}",
            "alt": "Alt Image Description"
          }
        ]
      }
    }
  ],