Skip to content
This repository has been archived by the owner on Apr 21, 2024. It is now read-only.

Unable to do basic web integration, request for example #23

Closed
RohanGautam opened this issue May 7, 2019 · 3 comments
Closed

Unable to do basic web integration, request for example #23

RohanGautam opened this issue May 7, 2019 · 3 comments

Comments

@RohanGautam
Copy link

Hello!
I've been trying to integrate this with the web template for botkit. I couldn't find any examples for it, there are only examples for facebook and slack.

Just to get it to work, my current basic code involves just bot.js and not the features directory.
Please take a look as this doesn't seem to work! More examples for web integration would also be a blessing.

const { Botkit } = require('botkit');
const { BotkitCMSHelper } = require('botkit-plugin-cms');
//Import dialogflow middleware
const dialogflowMiddleware = require('botkit-middleware-dialogflow')({
    keyFilename: 'keys/testaction-service-key.json',  // service account private key file from Google Cloud Console
});

// Import a platform-specific adapter for web.

const { WebAdapter } = require('botbuilder-adapter-web');

const { MongoDbStorage } = require('botbuilder-storage-mongodb');

const path = require('path');
// Load process.env values from .env file
require('dotenv').config();

let storage = null;
if (process.env.MONGO_URI) {
    storage = mongoStorage = new MongoDbStorage({
        url: process.env.MONGO_URI,
    });
}
const adapter = new WebAdapter({});

const controller = new Botkit({
    debug: true,
    webhook_uri: '/api/messages',
    adapter: adapter,
    storage
});

// if (process.env.cms_uri) {
//     controller.usePlugin(new BotkitCMSHelper({
//         cms_uri: process.env.cms_uri,
//         token: process.env.cms_token,
//     }));
// }

controller.middleware.receive.use(dialogflowMiddleware.receive);

controller.hears(['Default Welcome Intent'], 'message,direct_message,message_received', dialogflowMiddleware.hears, function (bot, message) {
    replyText = message.fulfillment.text;  // message object has new fields added by Dialogflow
    console.log(replyText, typeof replyText);
    bot.reply(message, replyText);
});
// make public/index.html available as localhost/index.html
// by making the /public folder a static/public asset
controller.publicFolder('/', path.join(__dirname,'.','public'));
console.log('Chat with me: http://localhost:' + (process.env.PORT || 3000));
@Naktibalda
Copy link

Provided code uses Botkit 4, this middleware hasn't been updated to support it yet.

@RohanGautam
Copy link
Author

ok, thanks! any plans to support it?

@jschnurr
Copy link
Owner

jschnurr commented May 9, 2019

No confirmed timing, but I will have a look at it.

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

No branches or pull requests

3 participants