I've setup a dockerized rasa installation to communicate to using a non dockerized react (mongo node express) frontend. I'm using the botfront webchat component as the chat component and I can send and receive messages correctly from rasa.
What I don't understand is how to make it so that different users (in the nodejs backend) can have different chats (in the rasa backend).
I've setup a custom connector for rasa and webchat using socketio which is setup to create a new sessionId at every connection event. This seems to work correctly as in the browser console I do see the following upon consecutive refresh:
connect:d01c6e80aa2647a186f087a4d1849ef9
session_confirm:d01c6e80aa2647a186f087a4d1849ef9 session_id:e50e1e9c87eb48c989d3d98022a0e8c3
connect:c6fc7aff5f0448a89ee54642561fe34c
session_confirm:c6fc7aff5f0448a89ee54642561fe34c session_id:2811d41ff0c44d398927d019b3d604f9
I assume the two session_ids being different means that the chat should appear empty, however the previous interactions are still visible.
Moreover, session_persistance is set to false in the credentials.yml file but this doesn't seem to have any influence
MySocketIO.WebchatInput:
user_message_evt: user_uttered
bot_message_evt: bot_uttered
session_persistence: false
And also in the widget itself I am setting the storage to session and not local:
<Widget
initPayload={"/get_started"}
socketUrl={"http://localhost:5005"}
socketPath={`/socket.io`}
customData={{"language": "en", 'ciccio':123}} // arbitrary custom data. Stay minimal as this will be added to the socket
params={{'storage':'session'}}
title={"Title"}
/>
I need to send the mongodb user._id of the specific user using the chat to the rasa custom actions and that is currently working through the customData, however I still cannot find out how to keep sessions of different users separate from each other.
Related
In my Strapi application, I have the following structure:
Footer(single type) > Section(component) > Menu(collection type) > link(component)
When performing a query Strapi only returns the id of the link and I needed its LABEL and URL, does anyone know how I can bring this in a query only?
Strapi section
Link Component
Footer API return
I used this topic on the Strapi forum, but without success yet
https://forum.strapi.io/t/how-do-i-return-only-selected-fields-from-the-model-and-its-relation/1115/2
Disclaimer; im new to Strapi.
The Strapi get requests only populates with relational data in a single layer of nesting. Your links looks to be on the second layer.
You have two options:
Query for the links by ID from your client after receiving the IDs. This can be done efficiently using Promise.all.
Modify the default GET handler for the ressource in the Strapi code. Extend the query to join on your links, and return the response in its entirity.
Update on option 2;
You can customize the logic behind any single endpoint handler in the API in your Strapi backend. The process is best descriped in their documentation on Custom Data Response's. Note that the syntax on how to query the database is based on a popular ORM depending on your database of choice. The ORMs are:
MongoDB (through Mongoose)
Postgres, MySQL, SQLite3 and more (through Bookshelf)
Redis (through ioredis).
I have 2 apps, each has its own html, js, css, etc . .
I have another app which loads the two apps from within iframes.
for example:
another-app.html:
<iframe src='app1.html' >
<iframe src='app2.html' >
and I also have a SDK which is written in plain JS where each one of the apps can use this SDK.js.
The goal is to send messages from one app to another via the SDK. what are my options ?
keep in mind the more than one instance of a specific app can be used and each instance (user) should have its own data id
The project I'm working on uses the feathers JS framework server side. Many of the services have hooks (or middleware) that make other calls and attach data before sending back to the client. If I have a new feature that needs to query a database but for a only few specific things I'm thinking I don't want to use the already built out "find" method for this database query as that "find" method has many other unneeded hooks and calls to other databases to get data I do not need for this new query on my feature.
My two solutions so far:
I could use the standard "find" query and just write if statements in all hooks that check for a specific string parameter that can be passed in on client side so these hooks are deactivated on this specific call but that seems tedious especially if I find this need for several other different services that have already been built out.
I initialize a second service below my main service so if my main service is:
app.use('/comments', new JHService(options));
right underneath I write:
app.use('/comments/allParticipants', new JHService(options));
And then attach a whole new set of hooks for that service. Basically it's a whole new service with the only relation to the origin in that the first part of it's name is 'comments' Since I'm new to feathers I'm not sure if that is a performant or optimal solution.
Is there a better solution then those options? or is option 1 or option 2 the most correct way to solve my current issue?
You can always wrap the population hooks into a conditional hook:
const hooks = require('feathers-hooks-common');
app.service('myservice').after({
create: hooks.iff(hook => hook.params.populate !== false, populateEntries)
});
Now population will only run if params.populate is not false.
I've tried to get the setUserContext function with raven-node in my nodejs app, but I cannot find how to set the user context. Has anyone made it work?
I was able to make it work in the client-side, with "Raven.setUserContext" but not in the nodejs backend :(
User context isn't implemented in raven-node: https://github.com/getsentry/raven-node/issues/134
I'm a contributor to the project, and it's my number one priority to have this done shortly – should be a matter of days.
Edit – we just published raven-node 0.10.0 which adds setUserContext.
I am working out how best to test an application we are developing using Laravel as backend (REST API) and Ember.js as front end.
I am currently using Behat to run acceptance tests for the API. I would like to use Cucumber.js to also create and test features for the Ember side of the project.
I already have an "acceptance" environment dedicated to running the Behat features in the API.
The issue I can see with "full stack" testing from the JS side is how to clean and reseed the database?
My thoughts are to add a route for testing purposes only, e.g.:
if ( App::environment() == 'acceptance' ) {
Route::get('/test/reseed', function() {
// delete db if exists
Artisan::call('migrate');
// call other migrations...
Artisan::call('db:seed');
return "ok";
});
}
This way only the acceptance environment has access to that call, and it should be all thats needed to set up the API side of things ready for Cucumber.js & Ember to run the tests (probably via Node.js)
I'm asking here to see if there is anything glaring I might have missed, if there is another way to do this.
The reason I want to be able to test purely from the JS side is so that we can test the systems independently of each other. I am aware I can test the full application with Behat, Mink and PhantomJS for example.