Botbuilder-dotnet: [Adaptive] Not able send base 64 image in adaptive dialog

Created on 1 Jun 2019  路  11Comments  路  Source: microsoft/botbuilder-dotnet

Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.

Version

4.5* latest Preview version

Describe the bug

Give a clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior:
want to send a base64 image in Adaptive Dialog.
Tried using AdaptiveCards.AdaptiveImage but it says Url is to bix in exception.

Expected behavior

Give a clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

[bug]

4.5 bug

All 11 comments

@sgellock thanks let me know if there is any work around.

@vidya091209 can you please clarify how you need to/ trying to send base64 image? By in lining the image in a card attachment or do you need to send this directly via the SendActivity step or something else?

```c#
var img = new AdaptiveCards.AdaptiveImage(i.message)
{
Type = i.message.Split(";")[0].Substring(5)
};

dialog.Steps.Add(img);
```

I am trying this, i think we can not use send activity for image. i am open to any idea.

@v-kydela, please investigate.

@vidya091209 - In order to determine if this is related to adaptive dialogs, can you successfully send the base64 image outside of an adaptive dialog?

@v-kydela yes i am able to send it outside the adaptive dialog.

@vidya091209 - Adaptive Cards are unrelated to adaptive dialogs, so naturally an adaptive image is not a valid adaptive dialog step. You can see all the types of steps available to you in the steps folder. What specific branch have you pulled in order to use adaptive dialogs?

@v-kydela I simply wanted to send a base64 image as step in adaptive dialog. i am using 4.Future branch.

@v-kydela I'm moving this over to the Adaptive team to address. Thanks for the initial help, but I'd like them to address the issue.

@tomlm @carlosscastro we should decide if we can get this fixed before the next train leaves.

You need to use a SendActivity(activity) step with Activity carying an Attachment object for the image.

If all you are trying to do is send an image as an activity then it would be something like this:

var activity = dc.TurnContext.Activity.CreateReply();
activity.Attachments.Add(new Attachment(contentType:"image/jpg", contentUrl:"base64:..."));
// this uses new CTOR that takes a raw activity, you need latest bits for this
dlg.Steps.Add(new SendActivity(activity));

// alternatively, you use a staticActivityTemplate() 
dlg.Steps.Add(new SendActivity() {  Activity = new StaticActivityTemplate(activity)});

all inline

dlg.Steps.Add(new SendActivity(new Activity()
    {
        Attachments = new Attachments[] {
            new Attachment(contentType:"image/jpg", contentUrl":"base64...") 
        }
    }));

If you are truly trying to send an AdaptiveCard, then you need to do the same thing but add an attachment with adaptive card that has an AdaptiveImage inside that.

Thanks a lot it worked.

Was this page helpful?
0 / 5 - 0 ratings