{
errors: [
'Plugin this-plugin-does-not-exist does not exist',
],
}
If we do
await app.c('chatbot')
.chat({
text: '2+2',
});
This should return:
{
errors: [
'Specify either a plugin or a conversationId',
],
}
Most of the work will be done by ./app/code/chatbot, and ./app/code/chatbotCalculator/index.js will look something like:
class ChatbotCalculator extends require('../component/index.js') {
async conversation(prompt, previous) {
/**
* previous will be something like:
* [] (if this is a new chat)
* or
* [
* {
* prompt: '2+2',
* result: '4',
* },
* ]
*/
If (!previous) {
// this is a new chat
return this.getResult(prompt);
}
else {
// this is a continuation of a chat
return this.getResult(previous[0].result + prompt);
}
}
dependencies() {
return [
'./chatbot/index.js',
];
}
}
Your task
In addition to making ChatbotCalculator, you will need to create Chatbot as well, which will be responsible for storing conversations in the database and directing them to the correct plugin.
Eventually we can add more plugins, such as a weather plugin, a translation plugin, an AI plugin, etc.
Download the latest branch of https://github.com/dcycle/starterkit-node
./scripts/deploy.sh
We want to have a text-based conversational framework with different plugins.
The first plugin will be a simple calculator.
Therefore there should be two (2) extensions added:
We would like to be able to do the following:
This should return:
Then we can do
This should return:
If we do
This should return:
If we do
This should return:
Most of the work will be done by ./app/code/chatbot, and ./app/code/chatbotCalculator/index.js will look something like:
Your task
In addition to making ChatbotCalculator, you will need to create Chatbot as well, which will be responsible for storing conversations in the database and directing them to the correct plugin.
Eventually we can add more plugins, such as a weather plugin, a translation plugin, an AI plugin, etc.