Closed chakir-alaoui closed 7 years ago
Hi @chakir-alaoui,
I believe you don't need to change the receive middleware based on the language. All you'd have to do is change the way you're initializing the middleware object (in app.js)
Just change the workspace_id
based on the result of your regex eval and use it for initializing the middleware obj like it's done here: https://github.com/watson-developer-cloud/botkit-middleware/blob/master/examples/multi-bot/app.js#L22
Let me know if that didn't help or you need more info. Good luck!
Ah I see. Then you're right, it must be done before the message is sent to Conversation. Did you try re-initializing the middleware.conversation
object inside middleware.before
function?
If you over-write it there with the appropriate workspace_id it should pick it up when postMessage
is invoked.
Give that a try..also if you run the code with the debug string 'watson-middleware:index' then it should print all debug statements inside https://github.com/watson-developer-cloud/botkit-middleware/blob/master/lib/middleware/index.js
i want to identify the input language and then in my backend select the specific workspace to keep the conversation, but i can't switch to the other workspace.
after detecting user language , i export it with module.exports.language to my app.js but when i use console.log to display the language : language undefined
Please suggest the best approach to achieve this.