microsoft / BotFramework-Composer

Dialog creation and management for Microsoft Bot Framework Applications
https://docs.microsoft.com/en-us/composer/
MIT License
870 stars 371 forks source link

File or attachment user input action in Composer v2.1.1 not working #8867

Closed anujprasad-eaton closed 2 years ago

anujprasad-eaton commented 2 years ago

I am trying to create an attachment input action in bot framework composer and followed these steps but I am getting the error message - "Object reference not set to an instance of an object" on emulator vesrion 4.14.0. Please find below the screen shot of the implementation and error message:

image

image

anujprasad-eaton commented 2 years ago

My Bot framework Composer version details:

Version: 2.1.1 Electron: 8.2.4 Chrome: 80.0.3987.165 NodeJS: 12.13.0 V8: 8.0.426.27-electron.0

ramfattah commented 2 years ago

Hey @anujprasad, is your intent to attach a file? It looks like your getting the error as the input from the card is a text rather than an attachment file. Run your bot and click on the upload file (paper clip icon) button on bottom left of the chat to attach a file. Please let me know if this helps.

anujprasad-eaton commented 2 years ago

@ramfattah Yes, my intent is to attach a pdf file. The input text "number" that you see in the screen shot is just a regular expression trigger to trigger the number dialog and the very first step on that dialog is to ask user for file attachment. It throws the error "Object reference not set to an instance of an object" even before prompting the user the message "Please upload your invoice". Ideally user should first see this prompt "Please upload your invoice" and then he/she would click on upload file (paper clip icon) button to attach a file, it should not throw the exception before that.

I have shared the composer authoring screen for "Prompt for a file and attachment" , do you find any anomaly in that implementation that could throw the exception - "Object reference not set to an instance of an object"?

anujprasad-eaton commented 2 years ago

Re-attaching the composer bot authoring screen:

image

drmanhatin commented 2 years ago

I'm facing the same issue.

drmanhatin commented 2 years ago

In my case the input prompt did not have any text, this is why it errored. Ui should reflect it being necessary or should be possible to not contain any value.

anujprasad-eaton commented 2 years ago

I figured out the root cause and solution, incase anyone facing similar issue: Exact steps to reproduce the issue:

  1. Select the + icon then select File or attachment from the Ask a question menu
  2. Enter Please send an image. in the Prompt field of the Properties pane.
  3. Switch to the User Input tab ()
    • Enter dialog.attachments in the Property field.
    • Enter all in the Output format field.
    • Enter "application/pdf" in the contentType. Note that contentType field is marked as mandatory
  4. Now run your bot and invoke the dialog that has prompt for file or an attachment - your get the error message - "Object reference not set to an instance of an object"

The root cause for the issue was contentType which is marked as mandatory field with red *, now even if I remove the text "application/pdf" from contentType field I continue to get the error message - "Object reference not set to an instance of an object". So the fix is to remove the control "prompt for file or an attachment" first and then re-add it and make sure you have not added any text in the mandatory field - "contentType " :).

image

anujprasad-eaton commented 2 years ago

Quick question - Once the file is uploaded by user using the prompt "File or attachment input", does that file stays in the server forever or it's stored in memory within dialog scope? If I have to hand it off to any live agent such as customer helpdesk, what's the best possible way to store the transcript and this file and then send it over an email to the live agent?

ramfattah commented 2 years ago

Hi @anujprasad , Microsoft Bot Framework is an open platform that allows developers to integrate with a variety of agent engagement platforms. This is the official Microsoft Documentation on Handoff integration models to provide a common language and best practices for bot developers and system integrators building conversational AI systems with human in the loop.

Also, Here is the Bot Framework v4 Handoff Library.

ParthHadkar1203 commented 2 years ago

Hi @anujprasad , Microsoft Bot Framework is an open platform that allows developers to integrate with a variety of agent engagement platforms. This is the official Microsoft Documentation on Handoff integration models to provide a common language and best practices for bot developers and system integrators building conversational AI systems with human in the loop.

Also, Here is the Bot Framework v4 Handoff Library.

can i get upload file url so i can store some where in api and the through api i will dowload it

ParthHadkar1203 commented 2 years ago

if user send me pdf attachment in bot composer. How I will store that pdf in my code. How it will convert to base 64 or in URL to send via API to store somewhere

ParthHadkar1203 commented 2 years ago

if user send me pdf attachment in bot composer. How I will store that pdf in my code. How it will convert to base 64 or in URL to send via API to store somewhere

My issue is resolved and it uploading in my blob storage and getting URL too. NOTE : Storing locally only

When I try to run through server its show error Below Error : An attempt was made to access a socket in a way forbidden by its access permissions. An attempt was made to access a socket in a way forbidden by its access permissions.

ParthHadkar1203 commented 2 years ago

how to used validation for file ie. file should be in .pdf format only in bot composer

RaviKasaudhan commented 1 year ago

if user send me pdf attachment in bot composer. How I will store that pdf in my code. How it will convert to base 64 or in URL to send via API to store somewhere

My issue is resolved and it uploading in my blob storage and getting the URL too. NOTE : Storing locally only

When I try to run through server its show error Below Error : An attempt was made to access a socket in a way forbidden by its access permissions. An attempt was made to access a socket in a way forbidden by its access permissions.

Hi Hadkar, Can you please explain the process you followed so that whatever the user uploads, you get the URL in blob storage? Right now, after the user uploads any pdf i get ContentURL which is having localhost link. After copy-pasting that localhost link to any website its downloading the file without the extension. Can you also say how did you solve this? Any help is much appreciated.

ParthHadkar1203 commented 1 year ago

See in my case I get the whole name i.e - filename.pdf etc In your case exactly what link are you getting? and my issue is still pending

chinubansal2014 commented 1 year ago

How to store this file to azure blob storage or sharepoint list ?

surlicki commented 1 year ago

I'm also searching the possibility of saving attachments to azure storage. My bot as channel is using Teams. What I done up to now - I used "prompt for a file or attachment" and get content url of the file. Im looking for the next steps. From web I found that file should be sent via http request to azure blob. Is it a proper way, should I use this content url? Is it possible to done form Bot Framework Composer or extra coding is necessary? I appreciate all advices.