Skip to content

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Donate us Support us Follow us on Twitter

Description

Simple API endpoint for bot chat with Nest framework and TypeScript.

Project setup

$ npm install

Compile and run the project

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Resources And Start Process

For this project it's need necessary to consider these points:

  1. It's important not to delete a csv file in the path 'src/resource' in the root directory. this is important for the API execution.
  2. For start process considere the next steps:
    • execute the command in the Project setup section
    • create an .env file in the root directory with an OPEN_EXCHANGE_API_KEY varibla that contain the access api key for Open Exchenge Rates API and a second variable OPEN_API_KEY for the access api pey for OpenAI chat completion API
    • If you need to define a specific port to start the project, you can specify a PORT variable in .env file. By defualt the application listens for this variable. -Now you can run one of the commands in the Compile and run the Project section, all this in a terminal in the root directory.

Execution of Endpoints

when the application is running you can use any type of method preferred by you to make the request to the following enpoints (this only abailible in localhost enviroment):

  • endpoint API Documentation

    description: This endpoint allows you to view more specific documentation of this API in the Swagger tecnology and can run endpoints in these visual interfaces.

    Request Example with CURL:

    curl -x GET "http://localhost:3000"
  • endpoint Chat with Bot

    description: This endpoint enables communication with the ai chat bot and allows different types of responses to be obtained. For this OpenAi Chat Completion API is used.

    Query params:

    Nombre Tipo Requerido Descripción
    message String Yes This message is the request sent by the user to OpenAi.

    Request Example with CURL:

    curl -x POST "http://localhost:3000/chat" \
    -H "Content-Type: application/json" \
    -d '{"message": "I am looking for a phone"}'
  • endpoint test searchProducts

    description: This endpoint enables a test to search for products in the csv file. By default the method uses 'Phone' to search for matches.

    Request Example with CURL:

    curl -x POST "http://localhost:3000/chat/searchProducts"
  • endpoint test convertCurrencies

    description: This endpoint allows a test to change values to other exchange rates. By default the method uses twelve dollars and changes this value to the Colombian rate. For this Open Exchange Rates API is used.

    Request Example with CURL:

    curl -x POST "http://localhost:3000/chat/convertCurrencies"

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages