I am trying to build a chatbot using botkit anywhere and nodejs. I don't want to use any third-party messaging platform. I refer to this link https://github.com/howdyai/botkit#build-your-bot and try to setup chatbot in nodejs application:
First, add it to your project:
npm install --save botkit
Then, add Botkit to your application code:
var Botkit = require('botkit');
var controller = Botkit.anywhere(configuration);
controller.hears('hello','direct_message', function(bot, message) {
bot.reply(message,'Hello yourself!'); });
But they don't mention how to call and where to call this code in the existing application.
Before you start you need a NLU middle ware. Since you don't want to use 3rd party services, you can use RASA NLU and Botkit has easy integration too.
https://github.com/RasaHQ/rasa_nlu
Then You can the below easy to use Botkit-Anywhere-RASA library.
https://github.com/matteoredaelli/botkit-starter-web-rasa-nlu
1) Star the RASA NLU server
2) Clone the starter project (#2) and run using "node ."
For Botkit Web anywhere:
I followed following URL steps:
https://botkit.ai/getstarted.html
after these steps my folder structure is like below:
you can navigate to public->client.js and here you can find method.
Related
I am trying to get started with Fly.io. I know Vue well and wanted to try Nuxt and Node.js. I cannot seem to figure out how to add server-side components and classes for handling AJAX requests.
I followed the official tutorial https://fly.io/docs/languages-and-frameworks/nuxtjs/
npm init nuxt-app#latest spec-land
create-nuxt-app v5.0.0
✨ Generating Nuxt.js project in spec-land
? Project name: spec-land
? Programming language: JavaScript
? Package manager: Npm
? UI framework: Element
? Template engine: HTML
? Nuxt.js modules: Axios - Promise based HTTP client
? Linting tools: (Press <space> to select, <a> to toggle all, <i> to invert selection)
? Testing framework: None
? Rendering mode: Single Page App
? Deployment target: Server (Node.js hosting)
? Development tools: jsconfig.json (Recommended for VS Code if you're not using typescript)
? What is your GitHub username? --
? Version control system: Git
🎉 Successfully created project spec-land
$ touch pages/index.js
$ npm run dev
After adding some front-end code, is this generated project equipped to run JavaScript on the server in the same fly.io deploy?
For a Nuxt2 app, you need to have Rendering Mode as Universal (SSR/SSG) or ssr: true in your nuxt.config.js file, otherwise, you will not have an isomorphic app.
Nuxt will run some code on the server side + client side (isomorphic), while some will be run only on the client side only.
The setup to have a serverMiddleware for Nuxt2 is as follows. Quite tricky and not working so well.
Nuxt3 handles that pretty well on the opposite side.
Overall, Nuxt2 does have some capabilities regarding server-side code but is not as flexible as Nuxt3. Tbh, if you want to use Nuxt2, I would recommend not trying to set up an actual database linked to it, but rather accessing it remotely via axios or like.
I'm developing a twilio function on a subaccount that needs to acces a twilio client on the main account. The function is being deployed through a Github action to the subaccount.
For this, on the subaccount function I have:
const mainClient = new twilio(context.MAIN_TWILIO_ACCOUNT_SID, context.MAIN_TWILIO_AUTH_TOKEN);
Then I need to access serverless.services but I'm getting serverless undefined therefore can't access services.
i.e.
return mainClient.serverless.services(...
I tested code locally and it worked but failed on deployment. Is it possible to access services on main account from a subaccount function??
Thanks.
For anyone experiencing a similar issue.
My problem was that deploying without being explicit about dependencies doesnt install the latests version of dependencies.
Deploy through github installed twilio node sdk version 3.29.0 but this version doesn includes serverless api yet. So I explicitly added latest twilio node sdk (3.75.0 at the moment) and that fixed the problem.
Thanks.
I want to add a Middleware in a Bot Framework Composer project but I can't find any documentation on how to do it.
How would one go about adding a simple Middleware, let's say a Middleware that logs all the exchanged messages to console, in a bot created with Bot Framework Composer v2.1.1?
you have to mention the middleware component name in "configure -> settings.json" file.
ex:
"components": [
{
"name": "BotComposerMiddlewareComponent"
}
],
Note : BotComposerMiddlewareComponent is a middleware component
name.
find the sample here how to write the custom middleware for bot composer
Create a class file
Inherit this interface - Microsoft.Bot.Builder.IMiddleware
Implement OnTurnAsync Method like below code sample
You will have access to context, Activity and other stuffs you do in bot framework library implementations
I have wrote a detailed article on creating middleware for Bot Framework Composer here:
https://www.lkgforit.com/2022/10/implementing-middleware-in-bot.html
I am creating an Electron app and am using electron-builder to package and build the app. Users are able to make plugins for the app (plugins can be node modules with their own dependencies and such). Everything is working fine except the part of the app for exposing the app's API to the plugin.
I created a module in the app for handling the plugins "Plugin-handler" that imports the plugin and also exposes the API to the plugin (The app's API is just a set of functions and it is bundled with the app).
The dilemma is that the user should be able to place a plugin anywhere on their machine and the app does not know the path before the build. Consequently, I excluded the "plugin-handler" module in the Electron-builder config so it does not bundle with the Webpack. Now I need to find the right way to expose the API to the plugin.
Here is how I am doing it now, to load the plugins and passing the API:
// In the Plugin-handler module
const API = require('api')
const plugin = require('path-to-plugin')( API )
path-to-plugin is added by the user in the app when they import their plugin.
As seen above, currently I pass the API to the plugin as an argument, which is not ideal, instead, I need a way to exposing the API module (or any other module that is bundled in the APP) to the plugin so users can access it in their plugin like below:
// In the plugin
const { arg1, arg2,... } = require('api')
I've seen apps doing this, and allowing users to access their API in their plugins, but since I am new to all this, I may be doing things wrong, so please do be kind, and thank you for the help!
I drew a simple chart for better portraying the question:
First of all, I'm developing a proyect in Ionic (front-end), Node.js + Express (backend) and MongoDB as DB and, I want to implement push notification in my app. I've read a lot about notification using firebase but I'm using MongoDB. I'm quite lost if anyone could help/guide me, I'd appreciate it.
You can use Firebase push or Firebase cloud messaging with your app without any issue. It is just one service of Firebase family. You don't need to use its real-time database with your app. You just need to integrate Firebase cloud messaging service only. i.e. you can keep Mongodb backend as it is now.
Article about Firebase Push and Ionic 4
If you don't want to use firebase and/or you want push notifications even if you are offline, there is this Cordova plugin you can use: cordova-plugin-local-notifications.
Quick instructions here. Not-so-quick instructions: read the documentations and issues in github.
Install like this:
ionic cordova plugin add cordova-plugin-local-notification
npm install #ionic-native/local-notifications
Then import and include the provider in app.module.ts (don't forget this step, usually not included in any manual):
import {LocalNotifications} from '#ionic-native/local-notifications/ngx';
...
providers: [ LocalNotifications ]
Then import and inject in your_page.page.ts:
import {LocalNotifications} from '#ionic-native/local-notifications/ngx';
...
constructor(private localNotifications: LocalNotifications) {}
And finally use it like this:
this.localNotifications.schedule({
title: 'My first notification',
text: 'Thats pretty easy...',
foreground: true
});
Test it thoroughly, the plugin is not bugfree, but works.
Hope this helps.