Navi Assistant Server is the backend service for the Navi Assistant project, providing essential functionalities such as user management, project handling, and integration with various APIs to enhance the application development experience.
- Description
- Components
- Installation
- Usage
- Features
- API Endpoints
- Import Dialogflow ES Agent
- Contributing
- License
- Contact
The NAVI Assistant server, implemented using Node.js, is responsible for business logic and data management, providing the necessary services to the web browser extension. Its functions include text localization in server responses and the reception, processing, and sending of real-time responses to the data sent by the extension. Moreover, the server offers methods to perform CRUD operations in the database, where user activity logs are stored. It integrates the Dialogflow platform to create personalized responses and features a static code analysis tool written in Python. It also includes a comparator that matches the user's code with the guided project's code during project development.
-
Register. This component, like its counterpart in the browser extension, contains the necessary classes and methods for creating objects that conform to the established data model, but in TypeScript. When the server receives information from the web extension, this component helps structure the incoming data.
-
Locale. This component contains the methods required to localize the various texts that form the server's responses. It uses the
i18n
library and JSON files where all translations for each supported language are stored. -
App. This component is essential because, using the
Express
tool, it can receive, process, and send appropriate real-time responses to data sent by the web extension viaSocket.IO
. This process includes activities such as guided project management, qualitative and quantitative evaluation of projects, and data storage in the database. Additionally, this component provides the necessary infrastructure to access multimedia content on the server host, used in responses from the web extension's chatbot, and to access the tool's web page. -
Controller. This component uses the
Sequelize
tool to provide the methods necessary for performing CRUD operations in the tool's database, which stores user usage records. -
Cards Creator. The function of this component is to provide various templates for creating the response cards displayed in the chatbot. Each method in this component provides a different pattern based on the Dialogflow Messenger documentation.
-
Dialogflow Webhook. This component integrates the Dialogflow platform with the server, allowing for the creation of personalized and automated responses for users. When a user interacts with the NAVI Assistant chatbot, their input is sent to Dialogflow for processing. If the detected intent's response indicates that the server should find the response, the platform will send the user's input to this server component. There, the information will be processed, and a personalized response will be sent back to Dialogflow, which will then display the server's response to the user in the chatbot.
-
Python Caller. This component is responsible for executing the static code analysis tool
dr-app-inventor
written in Python. Thanks to thepython-shell
module used by this component, it is not necessary to rewrite thedr-app-inventor
tool's code. -
Compare Form. This component is only used by the
App
component when the user is working on a guided project in the chatbot. Its task is to compare the design workspace code created by the user with that of the guided project. The result of this comparison is a series of natural language instructions indicating what changes the user should make in the design workspace to match the guided project code, whether adding, removing, or modifying elements. -
Compare Blocks. Like the previous component, this one is also only used by the
App
component when the user is carrying out a guided project in the chatbot. Its function is to compare the block workspace code generated by the user with that of the guided project. The result of this comparison is a series of natural language steps indicating what the user should add, remove, or change in the block workspace to align with the guided project code.
Follow these steps to set up the server:
- Clone this repository:
git clone https://github.com/lordrubenbp/navi-assistant-server.git
- Navigate to the project directory:
cd navi_assistant_server
- Install the necessary dependencies:
npm install
- Set up environment variables. Create a
.env
file and add your configuration:PORT=3000 DB_HOST=your_database_host DB_USER=your_database_user DB_PASS=your_database_password
- Start the server:
npm start
After setting up and starting the server, it will be running on the port specified in your .env
file (default is 3000). The server provides endpoints for various operations required by the Navi Assistant Extension.
- User Management: Handle user registration, authentication, and data management.
- Dialogflow Integration: Support for natural language processing to enhance user interactions.
- Real-time Communication: Use of websockets for real-time data exchange.
- Guided Projects: Provides guided projects that users can follow and compare with their own projects in development to ensure they are on the right track and to assist in troubleshooting.
Here are some of the main API endpoints provided by the server:
-
User Endpoints:
POST /api/register
: Register a new user.POST /api/login
: Authenticate a user and provide a token.GET /api/user
: Retrieve user information.
-
Project Endpoints:
POST /api/projects
: Create a new project.GET /api/projects
: Get a list of projects.PUT /api/projects/:id
: Update project information.DELETE /api/projects/:id
: Delete a project.
-
Dialogflow Endpoints:
POST /api/dialogflow/webhook
: Handle Dialogflow webhook requests.
To import the NAVI_ASSISTANT_AGENT.zip
file containing a Dialogflow ES conversational agent, follow these steps:
- Log in to your Dialogflow ES account at Dialogflow Console.
- Create a new agent or select an existing agent.
- Go to the agent's settings by clicking the gear icon next to the agent's name.
- In the "Export and Import" tab, select "Import".
- Click "Select file" and upload the
NAVI_ASSISTANT_AGENT.zip
file. - Confirm that you want to import the file. This will overwrite the current agent with the contents of the uploaded file.
Once the import is complete, the agent will be ready for configuration and use within Dialogflow ES.
Contributions are welcome! To contribute:
- Fork the project.
- Create a new branch (
git checkout -b feature-new-feature
). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-new-feature
). - Open a Pull Request.
Distributed under the MIT License. See LICENSE
for more information.
For any questions or inquiries, you can contact us through:
- Email: [email protected]
- Website: Navi Assistant