My First Playground

node v18.11.0
version: 1.0.0
endpointsharetweet
This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
require("@open-wa/wa-automate") // IT FAQs and answers const IT_FAQ = [ '1. How to reset my password?', '2. How to fix slow internet?', '3. How to setup email on my phone?', '4. How to recover deleted files?', '5. How to improve PC performance?', '6. How to resolve printer issues?', '7. How to update software on my system?', '8. How to protect my system from viruses?', '9. How to troubleshoot system boot issues?' ]; const FAQ_ANSWERS = { 1: 'To reset your password, follow these steps: [steps here]', 2: 'Slow internet may be due to [explanation and solution]', 3: 'To set up email on your phone, [instructions here]', 4: 'Deleted files can sometimes be recovered by [solution here]', 5: 'Improve PC performance by [suggestions]', 6: 'Resolve printer issues by [steps here]', 7: 'Update your software by [instructions here]', 8: 'To protect your system from viruses, [tips]', 9: 'Troubleshooting boot issues may involve [solutions here]', }; // Initialize WhatsApp Bot create({ sessionId: 'IT_FAQ_BOT', useChrome: true, headless: true, qrTimeout: 0, }).then((client) => { console.log('WhatsApp Bot is running and ready to receive messages.'); // Handle incoming messages client.onMessage((message) => { if (message.body.toLowerCase() === 'hello') { client.sendText(message.from, 'Hello! How can I assist you today? Type "menu" to see the available FAQs.'); } else if (message.body === 'menu') { const menuMessage = `Welcome to the IT FAQ Bot!\n\nPlease select a topic from the menu below by entering the number:\n\n${IT_FAQ.join('\n')}`; client.sendText(message.from, menuMessage); } else if (FAQ_ANSWERS[message.body]) { client.sendText(message.from, FAQ_ANSWERS[message.body]); } else { client.sendText(message.from, `Invalid option. Please type 'menu' to see the FAQ.`); } }); }).catch(err => { console.error('Error initializing WhatsApp Bot:', err); });
Loading…

no comments

    sign in to comment