IBM Watson Conversation - Unable to connect node.js to watson conversation - node.js

I have a Problem with an IBM Watson Conversation Application.
I have my Application set up and try to connect it to my node.js Application. I’m following this tutorial here:
https://github.com/watson-developer-cloud/node-sdk#conversation
and i am using the official node.js api ibm provides.
Unfortunately it does not work and i get following error.
{ Error: Not Authorized
at Request._callback (/Volumes/hd2/Projekte/vi-com-bot-service/node_modules/watson-developer-cloud/lib/requestwrapper.js:87:15)
at Request.self.callback (/Volumes/hd2/Projekte/vi-com-bot-service/node_modules/watson-developer-cloud/node_modules/request/request.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/Volumes/hd2/Projekte/vi-com-bot-service/node_modules/watson-developer-cloud/node_modules/request/request.js:1171:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (/Volumes/hd2/Projekte/vi-com-bot-service/node_modules/watson-developer-cloud/node_modules/request/request.js:1091:12)
at IncomingMessage.g (events.js:291:16)
at emitNone (events.js:91:20)
code: 401,
error: 'Not Authorized',
description: '2017-06-01T08:57:57-04:00, Error ERCDPLTFRM-DNLKUPERR occurred when accessing https://gateway.watsonplatform.net/conversation/api/v1/workspaces/dc8097e8-fea7-47a3-80ed-57c43321377e/message?version=2017-04-21, Tran-Id: gateway-dp01-2475007148 - Invalid UserId and/or Password. Please confirm that your credentials match the end-point you are trying to access. A common error is trying to use credentials from an experimental or beta release against a GA release or vice versa' }
The Credentials i provide are correct.
Do you have ay idea, why i does not work?
Best, ben

Bluemix has a number of regions where you can host services. There are different gateways into each region. By default it is https://gateway.watsonplatform.net.
For Germany + France Regions you would set the following URL variable in the code:
url: 'https://gateway-fra.watsonplatform.net/conversation/api/'
Like so:
var conversation = new ConversationV1({
username: '<username>',
password: '<password>',
url: 'https://gateway-fra.watsonplatform.net/conversation/api/',
version_date: ConversationV1.VERSION_DATE_2017_05_26
});
For other regions, you can go into the Watson conversation service credentials to see the URL. Or the conversation workspace "Deploy" then "Credentials" section.
This is the link to the revised IBM Cloud API for Watson Assistant including code samples for node.js and a list of URLs (see 'Service Endpoint').

var ConversationV1= require('watson-developer-cloud/conversation/v1');
var conversation = new ConversationV1({
username:'<username>',
password: '<Password>',
version_date: 'Date'
});
conversation.message({
workspace_id:'<Workspace Id>',
context: userContext,
input: {
"text": "<text>"
}
},function(err,resp){
});

Related

Bot framework composer not able to publish to Azure LUIS error

Is it something wrong with LUIS server? Can anyone help? it's working fine yesterday and today it's just not working suddenly.
The error was attached below:
"{"name":"StatusCodeError","statusCode":400,"message":"400 - {\"error\":{\"code\":\"BadArgument\",\"message\":\"Failed to parse azure account information object object.\"}}","error":{"error":{"message":"Failed to parse azure account information object object."}},"options":{},"response":{"statusCode":400},"stack":"StatusCodeError: 400 - {\"error\":{\"code\":\"BadArgument\",\"message\":\"Failed to parse azure account information object object.\"}}\n at new i (C:\\Users\\jenny.xue.wei\\AppData\\Local\\Programs\\Bot Framework Composer\\resources\\app.asar.unpacked\\extensions\\azurePublish\\lib\\node\\index.js:338:110597)\n at F.callback (C:\\Users\\jenny.xue.wei\\AppData\\Local\\Programs\\Bot Framework Composer\\resources\\app.asar.unpacked\\extensions\\azurePublish\\lib\\node\\index.js:338:109440)\n at F.e.callback.t.callback [as _callback] (C:\\Users\\jenny.xue.wei\\AppData\\Local\\Programs\\Bot Framework Composer\\resources\\app.asar.unpacked\\extensions\\azurePublish\\lib\\node\\index.js:338:108488)\n at F.t._callback.t.callback.t.callback (C:\\Users\\jenny.xue.wei\\AppData\\Local\\Programs\\Bot Framework Composer\\resources\\app.asar.unpacked\\extensions\\azurePublish\\lib\\node\\index.js:368:4017)\n at F.emit (events.js:210:5)\n at F. (C:\\Users\\jenny.xue.wei\\AppData\\Local\\Programs\\Bot Framework Composer\\resources\\app.asar.unpacked\\extensions\\azurePublish\\lib\\node\\index.js:368:16714)\n at F.emit (events.js:210:5)\n at IncomingMessage. (C:\\Users\\jenny.xue.wei\\AppData\\Local\\Programs\\Bot Framework Composer\\resources\\app.asar.unpacked\\extensions\\azurePublish\\lib\\node\\index.js:368:15546)\n at Object.onceWrapper (events.js:299:28)\n at IncomingMessage.emit (events.js:215:7)\n at endReadableNT (_stream_readable.js:1183:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"}"
"{"stack":"SyntaxError: Unexpected token o in JSON at position 1\n at JSON.parse ()\n at Object. (C:\\Users\\jenny.xue.wei\\AppData\\Local\\Programs\\Bot Framework Composer\\resources\\app.asar.unpacked\\extensions\\azurePublish\\lib\\node\\index.js:392:115579)\n at C:\\Users\\jenny.xue.wei\\AppData\\Local\\Programs\\Bot Framework Composer\\resources\\app.asar.unpacked\\extensions\\azurePublish\\lib\\node\\index.js:392:112703\n at Object.throw (C:\\Users\\jenny.xue.wei\\AppData\\Local\\Programs\\Bot Framework Composer\\resources\\app.asar.unpacked\\extensions\\azurePublish\\lib\\node\\index.js:392:112808)\n at s (C:\\Users\\jenny.xue.wei\\AppData\\Local\\Programs\\Bot Framework Composer\\resources\\app.asar.unpacked\\extensions\\azurePublish\\lib\\node\\index.js:392:111573)","message":"Unexpected token o in JSON at position 1"}"
"SyntaxError - Unexpected token o in JSON at position 1"
By the way, I contacted with the Microsoft support team and it's LUIS portal UI issue. Now it's all working as it before.
Add one more tag in publish profile for prediction Luis resource with name as luisResource.
Here is example:
"name": "composerBotName",
"environment": "test",
"luisResource": "prediction-luis-resource-name"

Message rejected under suspicion of SPAM Nodejs, Yandex, Firebase functions

I am trying to send email from my NodeJs Server using Yandex. Below is the process of creating transporter
let transporter = nodemailer.createTransport({
service: 'Yandex',
auth: {
user: process.env.EMAIL,
pass: process.env.PASSWORD
}
});
But it always fails showing the below messege:
{ Error: Message failed: 554 5.7.1 [2] Message rejected under suspicion of SPAM; https://ya.cc/1IrBc 1578999406-wC5neov7vv-ui00GIiO
at SMTPConnection._formatError (F:\ProjectFolder\Office\MXQ\Backend\mxq_server_firebase_functions\functions\node_modules\nodemailer\lib\smtp-connection\index.js:605:19)
at SMTPConnection._actionSMTPStream (F:\ProjectFolder\Office\MXQ\Backend\mxq_server_firebase_functions\functions\node_modules\nodemailer\lib\smtp-connection\index.js:1478:34)
at SMTPConnection._responseActions.push.str (F:\ProjectFolder\Office\MXQ\Backend\mxq_server_firebase_functions\functions\node_modules\nodemailer\lib\smtp-connection\index.js:968:2
2)
at SMTPConnection._processResponse (F:\ProjectFolder\Office\MXQ\Backend\mxq_server_firebase_functions\functions\node_modules\nodemailer\lib\smtp-connection\index.js:764:20)
at SMTPConnection._onData (F:\ProjectFolder\Office\MXQ\Backend\mxq_server_firebase_functions\functions\node_modules\nodemailer\lib\smtp-connection\index.js:570:14)
at TLSSocket._socket.on.chunk (F:\ProjectFolder\Office\MXQ\Backend\mxq_server_firebase_functions\functions\node_modules\nodemailer\lib\smtp-connection\index.js:522:47)
at TLSSocket.emit (events.js:198:13)
at TLSSocket.EventEmitter.emit (domain.js:448:20)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at TLSSocket.Readable.push (_stream_readable.js:224:10)
at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
code: 'EMESSAGE',
response:
'554 5.7.1 [2] Message rejected under suspicion of SPAM; https://ya.cc/1IrBc 1578999406-wC5neov7vv-ui00GIiO',
responseCode: 554,
command: 'DATA' }
Is it a problem with Yandex or from my side?
I had the same problem as you, but not all mailboxes can't accept emails.
Then, I found the answer in the official support documentation:
https://yandex.com/support/mail/bounces/other/message-rejected-under-suspicion-of-spam.html?lang=en
It is on your side, I had such an error before with another provider (not yendex), and solved it by signing the email, you need to get a DKIM and sign your email with it.
I had the same problem,
After a little bit research I applied method below :
I opened web interface of Yandex Email and manually sent some emails to my own email addresses, and then I've replied this emails back.
Just to prove to the system that this email account sends real letters .. it's not just a robot account.
P.S:
I was sending a welcome email to customers by using Nodemailer and Handlebars for the HTML templates. I'm not sure it's related.
I was getting the same error and I searched for the same and came here, the link posted by #Akira_Ant I clicked and I logged into the yandex service and then the mail from then on started flowing normally, so for me logging into the yandex.mail and then sending such signup mails [in fact all sorts password reset,otp and all in my case] worked. So i guess the solution might be logging in normally and keep logged in and then the service knows that the person is logged in so it may not be spam.

Microsoft Bot Framework - The Bot State API is deprecated. Please refer to https://aka.ms/I6swrh for details on how to replace

I installed the teams bot from this link https://github.com/OfficeDev/BotBuilder-MicrosoftTeams/tree/master/Node/samples inside of Teams and when I start testing the bot by messaging with "hello" in Teams I get the error below;
The Bot State API is deprecated. Please refer to https://aka.ms/I6swrh for details on how to replace with your own storage.
Error: GET to 'https://state.botframework.com/v3/botstate/msteams/conversations/19%3A2771d14b8fa2450ca52f97b941c3652f%40thread.skype%3Bmessageid%3D1568300852744' failed: [405] Method Not Allowed
at Request._callback (/home/me-myself-and-i/workspace/bot/BotBuilder-MicrosoftTeams/Node/samples/node_modules/botbuilder-teams/node_modules/botbuilder/lib/bots/ChatConnector.js:675:46)
at Request.self.callback (/home/me-myself-and-i/workspace/bot/BotBuilder-MicrosoftTeams/Node/samples/node_modules/request/request.js:185:22)
at Request.emit (events.js:182:13)
at Request.EventEmitter.emit (domain.js:459:23)
at Request.<anonymous> (/home/me-myself-and-i/workspace/bot/BotBuilder-MicrosoftTeams/Node/samples/node_modules/request/request.js:1161:10)
at Request.emit (events.js:182:13)
at Request.EventEmitter.emit (domain.js:459:23)
at IncomingMessage.<anonymous> (/home/me-myself-and-i/workspace/bot/BotBuilder-MicrosoftTeams/Node/samples/node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:273:13)
at IncomingMessage.emit (events.js:187:15)
But if I test from the Bot Framework Emulator, everything is fine and
I get a response when sending "hello
"
Anyone ran into that error?
I was able to resolve this issue by modifying the /samples/app.js file with the following 2 lines:
connector.resetAllowedTenants();
server.post('/api/v1/bot/messages', connector.listen());
var inMemoryStorage = new builder.MemoryBotStorage();
var bot = new builder.UniversalBot(connector).set('storage', inMemoryStorage);
// create the bot auth agent
var botSigninSettings = {
baseUrl: 'https://...',
fbAppClientId: 'fb app id',
fbAppClientSecret: 'fb app secret',
fbAppScope: 'public_profile,email,user_friends' // put Facebook access scope
};
The 2 lines that are key in the above code are:
var inMemoryStorage = new builder.MemoryBotStorage();
var bot = new builder.UniversalBot(connector).set('storage', inMemoryStorage);
The Bot State API was how, back in 2017, bot state was initially managed. It's been deprecated for almost 2 years now. My guess is that the sample you're using is built to call on it for state management, but the API no longer exists.
Additionally, the repo you linked is all v3 bots, and the Bot Framework is currently (as of Sept 2019) in v4.5. I would recommend, if you're getting started using the MS Bot Framework, to not start with v3, as they no longer receive the level of support that v4 bots do.
The Bot Framework team is actually putting in significant effort to integrate v4 with Teams fully. There is a sample currently in their sample repo here, that shows to use OAuth with Teams, for example.

Application Insights : Unable to verify the first certificate in node js

The application insights keeps on throwing the following error every few minutes.
ApplicationInsights:Sender [ 'Ingestion endpoint could not be reached 5 consecutive times. There may be resulting telemetry loss. Most recent error:',
{ Error: unable to verify the first certificate
at TLSSocket.\u003canonymous\u003e (_tls_wrap.js:1116:38)
at ZoneDelegate.invokeTask (/usr/src/app/node_modules/zone.js/dist/zone-node.js:275:35)
at Zone.runTask (/usr/src/app/node_modules/zone.js/dist/zone-node.js:151:47)
at TLSSocket.ZoneTask.invoke (/usr/src/app/node_modules/zone.js/dist/zone-node.js:345:33)
at emitNone (events.js:106:13)
at TLSSocket.emit (events.js:208:7)
at TLSSocket._finishInit (_tls_wrap.js:643:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:473:38) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' } ]
I reviewed the discussion GITHUB DISCUSSION and tried some proposed solution but it did not work.
Here is the code that I am using to connect to application insights.
let appInsights = require('applicationinsights');
appInsights.setup(config.APPINSIGHTS_KEY.trim())
.setAutoDependencyCorrelation(true)
.setAutoCollectRequests(true)
.setAutoCollectPerformance(true)
.setAutoCollectExceptions(true)
.setAutoCollectDependencies(true)
.setAutoCollectConsole(true)
.setUseDiskRetryCaching(true)
.start();
I am not 100% sure if there is any telemetry loss or not, but getting these errors all the time is annoying. Please help.
I've updated the github discussion thread. A fix on the ingestion side is in the works.
https://github.com/Microsoft/ApplicationInsights-node.js/issues/180#issuecomment-475699485

Application Insights: CorrelationIdManager error in node js

I am using application insights on my node js application and I keep on getting this error. Can you please help me
ApplicationInsights:CorrelationIdManager [ { Error: unable to verify the first certificate
at TLSSocket.<anonymous> (_tls_wrap.js:1105:38)
at ZoneDelegate.invokeTask (C:\src\xyz\xyz\xyz\node_modules\zone.js\dist\zone-node.js:275:35)
at Zone.runTask (C:\src\xyz\xyz\xyz\node_modules\zone.js\dist\zone-node.js:151:47)
at TLSSocket.ZoneTask.invoke (C:\src\xyz\xyz\xyz\node_modules\zone.js\dist\zone-node.js:345:33)
at emitNone (events.js:106:13)
at TLSSocket.emit (events.js:208:7)
at TLSSocket._finishInit (_tls_wrap.js:639:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' } ]
You're seeing this error because of transient problems on the Application Insights backend, but the error should not be fatal and your app should continue working as expected (albeit with this message being printed).
In the default configuration of the Application Insights SDK for Node.js, communication with the backend is retried - so you should be able to ignore this error and still see telemetry show up in the Azure Portal.
If you've changed the defaults, the setting you'll want to make sure to set is .setUseDiskRetryCaching(true) For example:
appInsights.setup("key")
.setUseDiskRetryCaching(true)
.start()
If you want to suppress messages like this from the SDK you can disable internal logging: (Be aware you'll be suppressing other errors potentially as well)
appInsights.setup("key")
.setUseDiskRetryCaching(true)
.setInternalLogging(false, false)
.start()
If you're curious about the history of this issue, and why it spontaneously occurs, there's a long-running issue on GitHub here: https://github.com/Microsoft/ApplicationInsights-node.js/issues/180

Resources