ai-customer-assistant
is a customer support chat bot powered by Google Generative AI. This package allows you to easily integrate an AI-powered customer support assistant into your projects.
- Responds to user queries with accurate, polite, and concise answers.
- Uses Google Generative AI to generate responses.
- Easy to integrate into any Node.js project.
Install the package using npm:
npm install ai-customer-assistant
Before using the package, you need to set up your Gemini API key:
- Create a
.env
file in your project's root directory. - Add your Gemini API key to the
.env
file:
API_KEY=your_api_key_here
Make sure to replace your_api_key_here
with your actual Gemini API key.
If you are using ES modules, ensure your package.json includes "type": "module"
:
{
"name": "your-project-name",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"ai-customer-assistant": "^1.0.0"
}
}
Then, you can import and use the ChatAssistant
class:
import { ChatAssistant } from 'ai-customer-assistant';
const chatAssistant = new ChatAssistant();
(async () => {
try {
const response = await chatAssistant.sendMessage("What are you doing?");
console.log("Response from AI Customer Assistant:", response);
} catch (error) {
console.error("Error:", error);
}
})();
If you are using CommonJS, you will need to dynamically import the package:
(async () => {
const { ChatAssistant } = await import('ai-customer-assistant');
const chatAssistant = new ChatAssistant();
try {
const response = await chatAssistant.sendMessage("What are you doing?");
console.log("Response from AI Customer Assistant:", response);
} catch (error) {
console.error("Error:", error);
}
})();
message
- The user's query.- Returns a Promise that resolves to the AI-generated response.
import { ChatAssistant } from 'ai-customer-assistant';
const chatAssistant = new ChatAssistant();
(async () => {
try {
const response = await chatAssistant.sendMessage("How can I reset my password?");
console.log("Response from AI Customer Assistant:", response);
} catch (error) {
console.error("Error:", error);
}
})();
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the ISC License - see the LICENSE file for details.