WPP-ASSISTANT

Streamline web interactions with WPP-Assistant AI!

license last-commit repo-top-language repo-language-count

Developed with the software and tools below.

JavaScript OpenAI JSON Express


Quick Links


Overview

WPP-Assistant streamlines WhatsApp interactions by integrating AI capabilities to send messages, contact owners, and manage conversations. It orchestrates webhooks, user data, and AI processing to enhance communication efficiency and user engagement. By connecting to MongoDB, OpenAI, and WhatsApp API, it enables automated message handling and AI-driven responses for seamless conversation management and user experience improvement.


Features

Feature Description
โš™๏ธ Architecture Node.js based architecture with Express for API, MongoDB for data storage, and integration with OpenAI for AI functionality. Modular design with clear separation of concerns. Centralized webhook controller for external service interactions.
๐Ÿ”ฉ Code Quality Consistent coding style, adheres to best practices. Good code readability and maintainability. Proper comments and documentation throughout the codebase.
๐Ÿ“„ Documentation Extensive documentation with code snippets, explanations, and summaries in key files like webhook.controller.js, userModel.js, and main.js. Readme file provides setup instructions and usage guidelines.
๐Ÿ”Œ Integrations Integrates with MongoDB for data storage, Express for API handling, and OpenAI for AI features. External dependencies include Mongoose and OpenAI API for seamless integration.
๐Ÿงฉ Modularity Codebase is modular with separate files for different functionalities like handling incoming messages, user data management, and AI interactions. Encourages code reuse and easy maintenance.
๐Ÿงช Testing Testing frameworks not explicitly mentioned in the repository contents. May benefit from the addition of unit tests or integration tests for improved reliability.
โšก๏ธ Performance Efficient architecture and code design. Utilizes asynchronous operations for improved responsiveness. Resource usage optimized through proper database interactions and AI processing.
๐Ÿ›ก๏ธ Security Secure handling of data with MongoDB integration. Authentication mechanisms in place for webhook interactions. Potential for further enhancements in data encryption and access control.
๐Ÿ“ฆ Dependencies Key dependencies include Mongoose for MongoDB interactions, Express for API handling, and OpenAI API for AI functionalities. Development dependencies include package-lock.json.
๐Ÿš€ Scalability Designed to handle increased traffic through the use of asynchronous processing, scalability potential with MongoDB for data storage, and Express for API routing. May require load testing for optimal scalability planning.

Repository Structure

โ””โ”€โ”€ WPP-Assistant/
    โ”œโ”€โ”€ config.env.example
    โ”œโ”€โ”€ package-lock.json
    โ”œโ”€โ”€ package.json
    โ””โ”€โ”€ src
        โ”œโ”€โ”€ api
        โ”‚   โ”œโ”€โ”€ app.js
        โ”‚   โ”œโ”€โ”€ controller
        โ”‚   โ”‚   โ””โ”€โ”€ webhook.controller.js
        โ”‚   โ”œโ”€โ”€ routes
        โ”‚   โ”‚   โ”œโ”€โ”€ index.routes.js
        โ”‚   โ”‚   โ””โ”€โ”€ webhook.routes.js
        โ”‚   โ””โ”€โ”€ service
        โ”‚       โ””โ”€โ”€ findThread.service.js
        โ”œโ”€โ”€ config
        โ”‚   โ”œโ”€โ”€ mongoose.js
        โ”‚   โ””โ”€โ”€ openAI.js
        โ”œโ”€โ”€ database
        โ”‚   โ””โ”€โ”€ model
        โ”‚       โ””โ”€โ”€ userModel.js
        โ”œโ”€โ”€ ia
        โ”‚   โ”œโ”€โ”€ createMessage.js
        โ”‚   โ”œโ”€โ”€ createNewThread.js
        โ”‚   โ”œโ”€โ”€ retrieveAssistant.js
        โ”‚   โ””โ”€โ”€ retrieveMessage.js
        โ”œโ”€โ”€ main.js
        โ””โ”€โ”€ skills
            โ”œโ”€โ”€ contactOwner.js
            โ”œโ”€โ”€ mainAI.js
            โ””โ”€โ”€ sendMessage.js

Modules

.
File Summary
package.json Code Snippet Summary:**webhook.controller.js processes incoming data in the WPP-Assistant repository, managing interactions with external services for handling webhook requests.
package-lock.json Code snippet-Webhook controller: Manages incoming requests for webhooks, verifying authentication and parsing data before passing to the main application.
config.env.example Code in webhook.controller.js manages incoming requests from webhooks, coordinating data retrieval with findThread.service.js for streamlined communication flow in the WPP-Assistant repository. This code plays a vital role in handling external interactions within the application architecture.
src
File Summary
main.js main.js` orchestrates configuration setup and API initialization for the WPP-Assistant repository, connecting to MongoDB and OpenAI before starting the application.
src.skills
File Summary
sendMessage.js Summary:**The sendMessage function in sendMessage.js sends a text message via HTTP POST request to a specified phone number using the provided message content. It interacts with an external endpoint for message delivery.
contactOwner.js Code Summary:**contactOwner.js in WPP-Assistant/src/skills sends a message to the owner via WhatsApp API. Involves constructing JSON payload and handling API request.
mainAI.js Summary:mainAI.js orchestrates AI interactions in the WPP-Assistant project. It processes AI responses, triggers actions, and directs interactions based on predefined criteria.
src.database.model
File Summary
userModel.js File Summary: userModel.js**Defines User model schema for MongoDB using Mongoose. Stores user details like name, contactPhone, and threadId. Essential for user data management in the WPP-Assistant app.
src.api
File Summary
app.js Code snippet in src/api/app.js sets up Express server, imports routes, and listens on port 3331. This file plays a critical role in the repository's architecture by defining the server's configuration and routing structure.
src.api.controller
File Summary
webhook.controller.js Code Summary:**webhook.controller.js handles incoming webhooks to find threads and process AI tasks. Key functions are to locate threads and run AI actions for conversations in the WPP-Assistant repository architecture.
src.api.routes
File Summary
webhook.routes.js Summary:** webhook.routes.js in WPP-Assistant routes requests to webhookController via Express Router, handling webhook interactions in the API layer.
index.routes.js Index routes connect to webhook routes using Express Router, managing API endpoint paths efficiently in the WPP-Assistant repository architecture.
src.api.service
File Summary
findThread.service.js Code in findThread.service.js locates thread ID by phone, creates new thread if needed, and saves user details. Essential for user engagement and data management in the WPP-Assistant repository.
src.config
File Summary
mongoose.js Code Summary**:In the mongoose.js file within WPP-Assistant/src/config, this code snippet establishes a connection to the MongoDB database using Mongoose, logging success or errors. This critical feature ensures seamless database connectivity in the repository architecture.
openAI.js Code Summary:**Enables OpenAI integration in the WPP-Assistant system by initializing OpenAI with API key and retrieving assistant details. Facilitates AI-powered features.
src.ia
File Summary
createNewThread.js Code Summary:**In createNewThread.js, it imports openAI config to create a new thread using OpenAI's API, returning the thread's ID. This supports AI-driven conversation functionality in the repository's architecture.
createMessage.js Role**: createMessage.js manages AI-assisted response creation within the WPP-Assistant repository. It leverages OpenAI to generate messages for specified conversation threads.
retrieveMessage.js Role:** retrieveMessage.js fetches message data from OpenAI for a chat thread in the WPP-Assistant repository.Features: Utilizes OpenAI API to retrieve messages with a delay for efficiency.
retrieveAssistant.js Summary:**retrieveAssistant.js retrieves assistant details using OpenAI API. It plays a key role in fetching assistant information for AI functionalities in the WPP-Assistant repository.

Getting Started

Requirements

Ensure you have the following dependencies installed on your system:

  • JavaScript: version x.y.z

Installation

  1. Clone the WPP-Assistant repository:
git clone https://github.com/thadeucbr/WPP-Assistant
  1. Change to the project directory:
cd WPP-Assistant
  1. Install the dependencies:
npm install

Running WPP-Assistant

Use the following command to run WPP-Assistant:

node app.js

Tests

Use the following command to run tests:

npm test

Project Roadmap

  • โ–บ INSERT-TASK-1
  • โ–บ INSERT-TASK-2
  • โ–บ ...

Contributing

Contributions are welcome! Here are several ways you can contribute:

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/thadeucbr/WPP-Assistant
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to GitHub: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.

Once your PR is reviewed and approved, it will be merged into the main branch.


License

This project is protected under the SELECT-A-LICENSE License. For more details, refer to the LICENSE file.


Acknowledgments

  • List any resources, contributors, inspiration, etc. here.

Return