Closed ghost closed 6 years ago
@vishwacsena
@carlosscastro
can you please help me with this error
Hi Schindar! I'm happy to help.
The image caption sample depends on some environment variables stored in the ".env" file. If you just copied and pasted the JavaScript code then you may be missing some of the extra files you need. It's a good idea to clone the whole repository to make sure you're not missing anything.
If you look inside caption-service.js, you can see the line var apiUrl = process.env.MICROSOFT_VISION_API_ENDPOINT + '/analyze?visualFeatures=Description'
in two places. What's happening here is that it's trying to get a URL from the environment variable MICROSOFT_VISION_API_ENDPOINT but the variable is undefined in your case. If you have the correct .env file, the variable should be defined as https://westus.api.cognitive.microsoft.com/vision/v1.0.
@v-kydela thanks for your response, i am getting the following error when i click on the link: { "statusCode": 404, "message": "Resource not found" } can u please help me further
@v-kydela i have now made the env. file called enviroment.plist on my MAC should i just copy and past the link " https://westus.api.cognitive.microsoft.com/vision/v1.0." in the file ? please help me i really need Instruction
Hey Schindar. Did you clone the repository?
Go ahead and have a look at the files for the image caption sample: https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/intelligence-ImageCaption
Among those files you will see a file called .env
: https://github.com/Microsoft/BotBuilder-Samples/blob/master/Node/intelligence-ImageCaption/.env
The contents of that file look like this:
# Bot Framework Variables
MICROSOFT_APP_ID=
MICROSOFT_APP_PASSWORD=
# Subscribe to Cognitive Services Computer Vision API to obtain a Trial Key.
# Subscription URL: https://www.microsoft.com/cognitive-services/en-us/subscriptions
MICROSOFT_VISION_API_KEY=
MICROSOFT_VISION_API_ENDPOINT=https://westus.api.cognitive.microsoft.com/vision/v1.0
As you can see, you are not supposed to "click on the link" but rather use the URL https://westus.api.cognitive.microsoft.com/vision/v1.0
as the value for the environment variable MICROSOFT_VISION_API_ENDPOINT.
Also note that you will need a value for MICROSOFT_VISION_API_KEY. As the comments say, you can get help obtaining a key from the link https://www.microsoft.com/cognitive-services/en-us/subscriptions. Yes, you are supposed to click that one. ;)
There are many sources where you can read more about NodeJS environment variables, such as: https://codeburst.io/process-env-what-it-is-and-why-when-how-to-use-it-effectively-505d0b2831e7 https://www.twilio.com/blog/2017/08/working-with-environment-variables-in-node-js.html https://nodejs.org/api/process.html
thank you very much for the help . i made it as you said it to me. i made a file calls .env and just puted the following -->
MICROSOFT_APP_ID=
MICROSOFT_APP_PASSWORD=
MICROSOFT_VISION_API_KEY=a6a1**
MICROSOFT_VISION_API_ENDPOINT=https://westus.api.cognitive.microsoft.com/vision/v1.0
but i still get the error only when i upload an image but i receive the texts.
"Error: Invalid URI "undefined/analyze?visualFeatures=Description"
at Request.init (/Users/admin/Desktop/chat2/node_modules/request/request.js:273:31)
at new Request (/Users/admin/Desktop/chat2/node_modules/request/request.js:127:8)
at request (/Users/admin/Desktop/chat2/node_modules/request/index.js:53:10)
at /Users/admin/Desktop/chat2/node_modules/request/index.js:61:12
at Function.post (/Users/admin/Desktop/chat2/node_modules/request/index.js:100:12)
at /Users/admin/Desktop/chat2/caption-service.js:27:33
at new Promise (
please guide me further
Can you post a screenshot of your bot's folder in File Explorer?
Also, did you clone the repository or not?
Please compare the code you copied with the code in the repo's app.js. Note that this line loads the environment variables from the .env file:
require('dotenv-extended').load();
thanks a lot. it helped me to much.but i have a last question before i close this issue , can you please tell me where i can finde a sample, which can Read text in images ? like this service : https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/
I'm glad to hear that we were able to solve your issue. Cognitive Services SDK has a number of samples available on the website: https://azure.microsoft.com/en-us/resources/samples/cognitive-services-node-sdk-samples/
I just made Copy and past for the Code samples of the image caption of node js. but i got the following error
"Invalid URI "Undefined/analyze?visualFeatures=Description " at request.init (C://****)"