|
| 1 | +<div align="center"> |
| 2 | +<br /> |
| 3 | +<p align="center"> |
| 4 | +<a href="https://wapijs.co"><img src="https://www.wapijs.co/assets/logo/logo-light.svg" alt="@wapijs/wapi.js" height="200" width="360" /></a> |
| 5 | +</p> |
| 6 | +<br /> |
| 7 | +<p> |
| 8 | + <a href="/"><img src="https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white" /></a> |
| 9 | + <a href="https://www.npmjs.com/package/@whatsappjs/Wapi.js"><img src="https://img.shields.io/badge/NPM-%23000000.svg?style=for-the-badge&logo=npm&logoColor=white" /></a> |
| 10 | + <a href=""><img src="https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white" /></a> |
| 11 | +</p> |
| 12 | +</div> |
| 13 | + |
| 14 | +## 📌 Status |
| 15 | + |
| 16 | +Beta Version - This library is not stable right now. It is currently in beta version. Report issues [here](https://github.com/sarthakjdev/wapi.js/issues). |
| 17 | + |
| 18 | +## 📖 About |
| 19 | + |
| 20 | +Wapi.js is a JavaScript module, written in TypeScript, designed to interact with the WhatsApp cloud API in a user-friendly manner. |
| 21 | + |
| 22 | +## ✨ Features |
| 23 | + |
| 24 | +- Object-Oriented Architecture |
| 25 | +- Single Client Model |
| 26 | +- Send Messages with the least configuration |
| 27 | +- Event Listener for Notifications (support both User and System Notifications) |
| 28 | +- Upload Media to WhatsApp servers |
| 29 | +- Reply and React to incoming messages. |
| 30 | + |
| 31 | +## 💻 Installation |
| 32 | + |
| 33 | +Ensure you have the Node.js 18 LTS version to use this library. |
| 34 | + |
| 35 | +```sh |
| 36 | +npm install wapi.js |
| 37 | +yarn add wapi.js |
| 38 | +pnpm install wapi.js |
| 39 | +``` |
| 40 | + |
| 41 | +> Note: This library is not affiliated with the official WhatsApp Cloud API or does not act as any official solution provided the the Meta Inclusive Private Limited, this is just a open source library built for developers to support them in building whatsapp cloud api based chat bots easily. |
| 42 | +
|
| 43 | +## 🚀 Usage |
| 44 | + |
| 45 | +- Kickstart your first WhatsApp application with Wapi.js. Check the [User Manual](./USER_MANUAL.md). |
| 46 | +- You can check out the example WhatsApp bot here. [Example Chatbot](./packages/example-chat-bot/) |
| 47 | +- You can get started with the development of your bot with this starter template utility. |
| 48 | + |
| 49 | +```sh |
| 50 | +pnpm create-wapi-bot |
| 51 | +``` |
| 52 | + |
| 53 | +## 🔗 References |
| 54 | + |
| 55 | +- **Message Structures**: Refer to the WhatsApp Docs [here](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages). |
| 56 | + |
| 57 | +- **Notification Payloads**: Details can be found [here](https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components). |
| 58 | + |
| 59 | +## 🔗 Other Links |
| 60 | + |
| 61 | +- [Website](https://wapijs.co) |
| 62 | +- [Documentation](https://wapijs.co/docs) |
| 63 | + |
| 64 | +## Example Usage |
| 65 | + |
| 66 | +```typescript |
| 67 | +import { Client, TextMessage } from 'wapi.js' |
| 68 | + |
| 69 | + const whatsappClient = new Client({ |
| 70 | + apiAccessToken: process.env.WHATSAPP_API_ACCESS_TOKEN, |
| 71 | + businessAccountId: process.env.WHATSAPP_BUSINESS_ACCOUNT_ID, |
| 72 | + phoneNumberId: process.env.WHATSAPP_PHONE_NUMBER_ID, |
| 73 | + port: 8080, |
| 74 | + webhookEndpoint: '/webhook', |
| 75 | + webhookSecret: process.env.WHATSAPP_WEBHOOK_SECRET |
| 76 | + }) |
| 77 | + |
| 78 | + await whatsappClient.message.send({ |
| 79 | + message: new TextMessage({ text: 'hiii, this is wapijs library' }), |
| 80 | + phoneNumber: 'XXXXXXXXXX' |
| 81 | + }) |
| 82 | + |
| 83 | + whatsappClient.on('TextMessage', (message) => { |
| 84 | + console.log(message) |
| 85 | + }) |
| 86 | + |
| 87 | + whatsappClient.on('TextMessage', async (message) => { |
| 88 | + message.reply({ |
| 89 | + message: new TextMessage({ text: 'hiii, this is wapijs library' }),, |
| 90 | + }) |
| 91 | + }) |
| 92 | + |
| 93 | + whatsappClient.initiate() |
| 94 | +``` |
| 95 | + |
| 96 | +## 🤝 Contribution Guidelines |
| 97 | + |
| 98 | +1. Fork the Project |
| 99 | +2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) |
| 100 | +3. Commit changes (`git commit -m 'Add some AmazingFeature'`) |
| 101 | +4. Push to the Branch (`git push origin feature/AmazingFeature`) |
| 102 | +5. Open a Pull Request |
| 103 | + |
| 104 | +For detailed guidelines, check [Contributing.md](./CONTRIBUTING.md). |
| 105 | + |
| 106 | +## 📜 License |
| 107 | + |
| 108 | +Distributed under the Apache 2.0 License. View [LICENSE](./LICENSE). |
| 109 | + |
| 110 | +## 📞 Contact |
| 111 | + |
| 112 | +- [Sarthak Jain](https://sarthakjdev.com) |
| 113 | +- Email: sarthak@softlancer.co |
| 114 | +- [Twitter](https://twitter.com/sarthakjdev) | [LinkedIn](https://www.linkedin.com/in/sarthakjdev) |
| 115 | + |
| 116 | +Note: This library is part of an open-source product-building initiative by [Softlancer](https://github.com/softlancerhq), and this repository will soon be moved under the same organization. |
0 commit comments