Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal TypeError: cannot read property 'output' of undefined #1

Open
dnorton94 opened this issue Dec 18, 2017 · 9 comments
Open

Fatal TypeError: cannot read property 'output' of undefined #1

dnorton94 opened this issue Dec 18, 2017 · 9 comments

Comments

@dnorton94
Copy link

@desmarchris Thanks for this! I was led here by the YouTube video 'Watson Conversation - Integrations Tutorial' However, I am currently running into some issues...

C:\Users\dnort\Desktop\sms-bot>node app.js
Initializing Botkit v0.5.4
info: ** No persistent storage method specified! Data may be lost when process shuts down.
info: *> Listening on port 8000
info: *> Serving webhook endpoint DESKTOP-7T4STH1:8000/sms/receive
TwilioSMSBot is online!
info: => Got a message hook
Fatal TypeError: Cannot read property 'output' of undefined
at C:\Users\dnort\Desktop\sms-bot\app.js:30:45
at C:\Users\dnort\Desktop\sms-bot\node_modules\botkit-middleware-watson\lib\middleware\index.js:121:9
at tryCatcher (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\promise.js:512:31)
at Promise._settlePromise (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\promise.js:569:18)
at Promise._settlePromise0 (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\promise.js:614:10)
at Promise._settlePromises (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\promise.js:693:18)
at Promise._fulfill (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\promise.js:638:18)
at Promise._resolveCallback (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\promise.js:432:57)
at Promise._settlePromiseFromHandler (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\promise.js:524:17)
at Promise._settlePromise (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\promise.js:569:18)
at Promise._settlePromise0 (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\promise.js:614:10)
at Promise._settlePromises (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\promise.js:689:18)
at Async._drainQueue (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\async.js:133:16)
at Async._drainQueues (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\async.js:143:10)
at Immediate.Async.drainQueues (C:\Users\dnort\Desktop\sms-bot\node_modules\bluebird\js\release\async.js:17:14)

How would you suggest I resolve this?

Thank You

@ahendo026
Copy link

I am receiving the same error. Please advise.

@desmarchris
Copy link
Owner

desmarchris commented Jul 16, 2018

can you try taking out the index here? Line 30: bot.reply(message, message.watsonData.output.text[0]);

@Abishek09
Copy link

Hi Chris, great tutorial ! I'm facing the same error. Tried removing the index but it still isn't working.

@desmarchris
Copy link
Owner

Check if your region is using IAM auth rather than standard username;password as well.. I just added a bit of code to app.js to use if you are using IAM auth (this was @ahendo026 's issue)

@Abishek09
Copy link

Abishek09 commented Jul 24, 2018

I'm using the IAM auth.
I made the changes that you've added in the app.js file but I'm still getting the error.
Could there be any other reason for the error?
Thanks for your response!

@desmarchris
Copy link
Owner

If it's the error above, then the call to Watson is what's not working. Can you share what you are putting in the url parameter? (Note, there aren't any API creds that need to be in the URL)

@Abishek09
Copy link

url:'https://gateway-wdc.watsonplatform.net/assistant/api'
This is the URL parameter in my app.js

Here's how the entire code looks:

'use strict'

require('dotenv').config({silent: true});

var middleware = require('botkit-middleware-watson')({
iam_apikey:'6S9SCsbZVqAKiRvCW5Tp4lxPCV6ME6WXwqJFMy0UL24E',
url:'https://gateway-wdc.watsonplatform.net/assistant/api',
workspace_id:'8eb38102-3595-412c-8266-85d9b25a204c',
version:'2018-07-10'
});

var TwilioSMSBot = require('botkit-sms');
var controller = TwilioSMSBot({
account_sid: process.env.ACCOUNT_SID,
auth_token: process.env.AUTH_TOKEN,
twilio_number: process.env.TWILIO_NUMBER
});

let bot = controller.spawn({})

controller.setupWebserver('5500', function (err, webserver) {
if (err) console.log(err)
controller.createWebhookEndpoints(controller.webserver, bot, function () {
console.log('TwilioSMSBot is online!');
})
});

controller.hears(['.*'], 'message_received', function (bot, message) {
middleware.interpret(bot, message, function(err) {
bot.reply(message, message.watsonData.output.text[0]);
})
});

Note: my local server is at port 5500.

@desmarchris
Copy link
Owner

@Abishek09 did you run npm update after taking in the IAM code? URL looks fine. Also I would modify that so you aren't sharing your creds :)

@abhijit-nimbalkar
Copy link

@desmarchris Hey Chris,
Thanks for the tutorial. I have a question. How can I send the context variable to the watson with a received message from Twilio? Sorry, I could not find any other communication channel to reach you.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants