ryanvolum / offline-directline

Unofficial package to emulate the bot framework connector locally.
https://www.npmjs.com/package/offline-directline
78 stars 44 forks source link

Error when running direcline #1

Open Nostreum opened 7 years ago

Nostreum commented 7 years ago

Hi !

I tried your solution and got this error :

module.js:471 throw err; ^

Error: Cannot find module 'C:\Users\h21178\Desktop\offline_dl-master\dist\cmdutil.js' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:389:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:504:3

Command :

npm run directline 3000 localhost://127.0.0.1:3979/api/messages

Thanks :)

ryanvolum commented 7 years ago

Did you pull the code from github and run it? or did you pull down the package from npm? If the former, because it's a typescript project you have to build it using npm run build.

It should be easier to just npm install the package though!

mohdkhan786 commented 7 years ago

Hello ryan I tried your solution but it is not working and getting below error.

0 info it worked if it ends with ok 1 verbose cli [ 'C:\Program Files\nodejs\node.exe', 1 verbose cli 'C:\Users\user1\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'run', 1 verbose cli 'directline', 1 verbose cli '3000', 1 verbose cli 'localhost:///SampleBot/api/messages' ] 2 info using npm@3.10.10 3 info using node@v6.11.0 4 verbose stack Error: ENOENT: no such file or directory, open 'D:\NodeDirectline\package.json' 4 verbose stack at Error (native) 5 verbose cwd D:\NodeDirectline 6 error Windows_NT 6.1.7601 7 error argv "C:\Program Files\nodejs\node.exe" "C:\Users\user1\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "directline" "3000" "localhost:///SampleBot/api/messages" 8 error node v6.11.0 9 error npm v3.10.10 10 error path D:\NodeDirectline\package.json 11 error code ENOENT 12 error errno -4058 13 error syscall open 14 error enoent ENOENT: no such file or directory, open 'D:\NodeDirectline\package.json' 15 error enoent ENOENT: no such file or directory, open 'D:\NodeDirectline\package.json' 15 error enoent This is most likely not a problem with npm itself 15 error enoent and is related to npm not being able to find a file. 16 verbose exit [ -4058, true ]

Below are steps I did in my machine .

  1. Created a "Samplebot" using VisualStudio C# which returns number of characters from typed message (default out of the box from bot template)

  2. Then I deployed it to local IIS and "http://localhost/SampleBot/api/messages" works fine. I can use this endpoint in Bot Emulator and is works fine.

  3. Created a folder "NodeDirectline" in my D drive and then using npm i installed your package D:\NodeDirectline>npm install --save offline-directline So far all good and package installed in this folder.

  4. Then finally I ran below command which return error npm run directline 3000 localhost:///SampleBot/api/messages

Is this fine or I am doing something wrong.I am not a node guy but for this solution i installed node in my machine.

Thanks

ryanvolum commented 7 years ago

@mohdkhan786 sorry you're running into issues. There may be a problem with the npm script approach right now. Can you try creating an app.js with the following code (and your own parameters in the initializeRoutes function) and try running it (node app.js in the cmd line)?

const directline = require("offline-directline");
const express = require("express");

const app = express();
directline.initializeRoutes(app, "http://127.0.0.1:3000", "http://127.0.0.1:3978/api/messages");
mohdkhan786 commented 7 years ago

Hello @ryanvolum , As per your suggestion ,i performed below steps but still one issue. I think I am very close.your help is needed in last step.

step 1 => I created a new app.js file in "NodeDirectline" folder as per mention in my previous steps with below code

const directline = require("offline-directline"); const express = require("express"); const app = express(); directline.initializeRoutes(app, "http://127.0.0.1:3000", "http://localhost/AppointmentBot/api/messages");

Run mycode (node app.js in the command line) and it display a messsage "listening". D:\POC\NodeDirectline>node app.js listening

step 2 => downloaded Microsoft/BotFramework-WebChat from github and unzip it Then updated below code in ..\samples\fullwindow\Index.html directLine: { secret: params['s'], token: params['t'], domain: params['domain'], webSocket: false }

npm install npm build npm start

Now I have a bot running and directline endpoint running.

Step 3: ==> Then Open url in browser http://localhost:8000/samples/fullwindow/?domain=http://127.0.0.1:3000/directline&botid=MyAppointmentBot&botname=MyAppointmentBot&userid=user1

. I can check a conversation id is also created in command line.

but now when i type something and press enter, it always says "could not send"

chat

Thanks for your help..

ryanvolum commented 7 years ago

@mohdkhan786 is your bot running locally at http://localhost/AppointmentBot/api/messages? Your bot should be receiving messages and replying to them. It seems odd that that bot endpoint doesn't have a port. Are you able to test your bot in the emulator with that endpoint?

I've identified the "couldn't send retry" return from webchat as a bug, and will implement a fix, but either way you should still be seeing messages from your bot.

mohdkhan786 commented 7 years ago

My bot in C# I have hosted in local IIS server and not express IIS. Yes I can use same URL in bot emulator and it works fine.

Do you suggest some other approach with port number?

mohdkhan786 commented 7 years ago

Is this code works only with express IIS and not with local server. Default port for local IIS is 80

const express = require("express"); const app = express();

ryanvolum commented 7 years ago

@mohdkhan786 the port number really shouldn't matter. This package is just setting up a REST service that your bot and your client can both make calls against. I've since tested the package with a C# bot and everything seems to be working. Are you sure you're passing the right URLs into the initializeRoutes function? The first should be where you want to host the connector, and the second should be the endpoint where your bot is hosted (including api/messages)

mohdkhan786 commented 7 years ago

Hello @ryanvolum @ryvolum

After my further investigation, I identified one problem may be help you to check. This solution is working fine for me when i create my bot using [Microsoft.bot.builder Version 3.0.0.0] but when I upgrade this to [Microsoft.bot.builder Version 3.9.0.0] then comes the problem and not sending request.

What I mean is same sample string length bot works with Ver3 but when i upgrade bot builder, then problem comes.Then It will not work even if we downgrate bot builder version t0 Ver 3.0.0.0 Is there anything in your offline directline dl which depends on Version3.0.0.0

Will be really helpful if you suggest something. image

Regards mohd

image

@ryanvolum I followed all steps . my ap.js is running , my webchat code is running but getting error in sending request image

image

image

image

mohdkhan786 commented 7 years ago

@ryanvolum
hi ryan did you get chance to address issue which I am facing in offline direct as explained above.

thanks in advance

Alanillinois commented 6 years ago

@ryanvolum Hi Ryan, I am also facing the same issue as raised by @mohdkhan786 . I have deployed the repo as mentioned in your post but not able to send the message successfully. Please guide me to resolve this.

Error message on command prompt, while sending the message in the Web-Chat client.

Created conversation with conversationId: da7191c9-4433-4c8a-b6f3-0cc29bc46a21 (node:16495) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): FetchError: request to http://127.0.0.1:3978/api/messages failed, reason: connect ECONNREFUSED 127.0.0.1:3978

Regards, Alan