Oyen
Oyen

Reputation: 436

How to receive Attachment in Form Dialog?

I currently have a Bot Dialog that asks for and receives attachments from the user. I would like to convert it into a Form Dialog because I think that fits better ("Please send me document1"... upto documentN). Can you point me to an example of Form Dialog that receives attachments from the user?

I read that FormFlow now has Attachment support: https://github.com/Microsoft/BotBuilder/pull/2870/commits/55c3d336a6cd63ee96561eeed9a905fb8c156a87#diff-db1cd0aff903bd4f06fadb81b6f33d86

I cannot find any example aside from: https://github.com/southworkscom/BotBuilder/blob/55c3d336a6cd63ee96561eeed9a905fb8c156a87/CSharp/Samples/Microsoft.Bot.Sample.FormFlowAttachmentsBot/ImagesForm.cs This one uses an AwaitableAttachment object. I can't figure out where it comes from...

Ideally I want to receive a List from the user, much like how a user can send multiple attachments and I in a normal dialog, I can retrieve it with messages.Attachments

List doesn't work and neither does normal Attachment object type like:

    [Prompt("Send me a copy of your **Document 1**.")]
    public Attachment Doc1;

    [Prompt("Send me a copy of your **Document 2**.")]
    public Attachment Doc2;

    ...

    private static IForm<MyForm> BuildMyForm()
    {
        OnCompletionAsyncDelegate<MyForm> completeForm = async (context, state) =>
        {
            //await context.PostAsync($"Completed.");
        };

        var form = CreateCustomForm<MyForm>()
                    .Message("Let's start!")
                   .Field(nameof(Doc1))
                   .Field(nameof(Doc2))
                 ...
                    .OnCompletion(completeForm)
                    .Build();

        return (IForm<MyForm>)form;
    }

Upvotes: 2

Views: 419

Answers (1)

Nicolas R
Nicolas R

Reputation: 14619

You were on the right way: the pull request that you found has been merged on develop branch of BotBuilder GitHub's project, that's why you are not seeing it in master releases.

You can find:

  • The sample of Attachment bot added with the pull request you pointed here
  • AwaitableAttachment class is here

Upvotes: 4

Related Questions