Core Components#
Bot Configuration#
Full configuration parameters for WhatsappGptBot:
interface GPTBotConfig extends BotConfig {
/** OpenAI API key */
openaiApiKey: string;
/** Model for generating responses (default: gpt-4o) */
model?: OpenAIModel;
/** Maximum number of messages to store in the conversation history (default: 10) */
maxHistoryLength?: number;
/** System message to define the assistant's behavior */
systemMessage?: string;
/** Temperature to generate responses to (default: 0.5) */
temperature?: number;
/** Default response when an error occurs */
errorMessage?: string;
// All configuration options from the core WhatsAppBot library are also available
// See the @green-api/whatsapp-chatbot-js-v2 documentation for more options
}
WhatsappGptBot#
The main class for creating and managing your WhatsApp bot with OpenAI:
const bot = new WhatsappGptBot({
// Required parameters
idInstance: "your-instance-id",
apiTokenInstance: "your-token",
openaiApiKey: "your-openai-api-key",
// Optional GPT-specific parameters
model: "gpt-4o",
maxHistoryLength: 15,
systemMessage: "You are a helpful assistant specializing in customer support.",
temperature: 0.7,
errorMessage: "Sorry, I was unable to process your request. Please try again again.",
// Optional parameters from the base bot
defaultState: "greeting",
sessionTimeout: 300,
// See the base library documentation for additional options
});