<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ritu Raj Singh</title>
    <description>The latest articles on DEV Community by Ritu Raj Singh (@riturajsingh878).</description>
    <link>https://dev.to/riturajsingh878</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F362023%2Fadd79b71-cb54-4d25-95d0-c8de15019007.jpeg</url>
      <title>DEV Community: Ritu Raj Singh</title>
      <link>https://dev.to/riturajsingh878</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/riturajsingh878"/>
    <language>en</language>
    <item>
      <title>Create a simple and free whatsapp bot: For Begineers</title>
      <dc:creator>Ritu Raj Singh</dc:creator>
      <pubDate>Fri, 03 Sep 2021 15:44:50 +0000</pubDate>
      <link>https://dev.to/riturajsingh878/how-to-create-a-simple-whatsapp-bot-d1b</link>
      <guid>https://dev.to/riturajsingh878/how-to-create-a-simple-whatsapp-bot-d1b</guid>
      <description>&lt;p&gt;This whatsapp bot can be used to send an automated message to individuals or groups. We can extend this bot for further use such as sending image/video, location, contacts.&lt;/p&gt;

&lt;p&gt;I will be using &lt;a href="https://www.npmjs.com/package/venom-bot"&gt;venom-bot&lt;/a&gt; node module to create this whatsapp bot. Venom module is a high-performance system developed with JavaScript and it is contineously developing with new features and it is open source-project so totally free.&lt;/p&gt;

&lt;h3&gt;
  
  
  Requirements:
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Development Environment (VS studio)
 Basics of JavaScript
 Basic Knowledge of Node Package Manager(NPM)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;First, we need to create a folder(maybe with the name "wpbot") and go into the created folder.&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps:
&lt;/h3&gt;

&lt;p&gt;1) open command/terminal in present folder&lt;br&gt;
2) give command &lt;strong&gt;npm init&lt;/strong&gt;&lt;br&gt;
It will automatically create a file &lt;strong&gt;package.json&lt;/strong&gt; in the current folder.&lt;br&gt;
3) create an &lt;strong&gt;index.js&lt;/strong&gt; file in the current folder.&lt;br&gt;
4) Now it's time to install the required vemon node module, give command &lt;strong&gt;npm i --save venom-bot&lt;/strong&gt;. It will install the required node module and it will automatically create a new file named &lt;strong&gt;package-lock.json&lt;/strong&gt;, which contains the installed package list.&lt;/p&gt;

&lt;p&gt;Time to do some coding....&lt;br&gt;
Open the index.js file in the development environment and paste the below code into the index.js file, that's it for now.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Supports ES6
// import { create, Whatsapp } from 'venom-bot';
const venom = require('venom-bot');

venom
  .create()
  .then((client) =&amp;gt; start(client))
  .catch((erro) =&amp;gt; {
    console.log(erro);
  });

function start(client) {
  client.onMessage((message) =&amp;gt; {
    if (message.body === 'Hi' &amp;amp;&amp;amp; message.isGroupMsg === false) {
      client
        .sendText(message.from, 'Hello Dear')
        .then((result) =&amp;gt; {
          console.log('Result: ', result); //return object success
        })
        .catch((erro) =&amp;gt; {
          console.error('Error when sending: ', erro); //return object error
        });
    }
  });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see from the code, whenever you will get a &lt;strong&gt;Hi&lt;/strong&gt; message from indivisual(not from group), bot will automatically reply &lt;strong&gt;Hello Dear&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;5) To create/activate this bot, you need to open you command/terminal and give the &lt;strong&gt;node index.js&lt;/strong&gt; command and it will open a QR code in the terminal/command. You need to scan the QR code and linked it. After this step, it will do the job.&lt;/p&gt;

&lt;p&gt;That's all for today, I'm still developing the complex features like sending replies as GIF/image based on text analysis and many more. I'll update you in future. Till then, stay safe and connected.&lt;/p&gt;

</description>
      <category>node</category>
      <category>visualstudio</category>
      <category>javascript</category>
      <category>venom</category>
    </item>
  </channel>
</rss>
