A progressive Node.js framework for building efficient and scalable server-side applications.
Simple API endpoint for bot chat with Nest framework and TypeScript.
$ npm install# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prodFor this project it's need necessary to consider these points:
- 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.
- 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.
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 Documentationdescription: 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 Botdescription: 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 messageString 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 searchProductsdescription: 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 convertCurrenciesdescription: 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"