Step 1: Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "ReceiveSmsWhatsApp" and then click OK

Step 2: Download WhatsApp API. This is an API written in C# but it can be used in any .NET language. It's a fork from WhatsAPINet, which is based on Chat API
Step 3: Design your form as below

Step 4: Add code to handle your form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using WhatsAppApi;
namespace ReceiveSmsWhatsApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private delegate void UpdateTextBox(TextBox textbox, string value);
private void UpdateDataTextBox(TextBox textbox, string value)
{
//Update textbox
textbox.Text += value;
}
private void btnReceive_Click(object sender, EventArgs e)
{
txtStatus.Clear();
//Create a new thread
var thread = new Thread(t =>
{
UpdateTextBox textbox = UpdateDataTextBox;
WhatsApp wa = new WhatsApp(txtPhone.Text, txtPassword.Text, txtName.Text, true);
wa.OnConnectSuccess += () =>
{
if (txtStatus.InvokeRequired)
Invoke(textbox, txtStatus, "Connected...");
wa.OnLoginSuccess += (phone, data) =>
{
if (txtStatus.InvokeRequired)
Invoke(textbox, txtStatus, "\r\nConnection success !");
wa.PollMessages();
};
wa.OnGetMessage += (node, from, id, name, message, receipt_sent) =>
{
if (txtStatus.InvokeRequired)
Invoke(textbox, txtStatus, string.Format("\r\nName = {0}, Message = {1}", name, message));
};
wa.OnLoginFailed += (data) =>
{
if (txtStatus.InvokeRequired)
Invoke(textbox, txtStatus, string.Format("\r\nLogin failed {0}", data));
};
wa.Login();
};
wa.OnConnectFailed += (ex) =>
{
if (txtStatus.InvokeRequired)
Invoke(textbox, txtStatus, string.Format("\r\nConnect failed {0}", ex.StackTrace));
};
wa.Connect();
}) { IsBackground = true };
thread.Start();
}
}
}
VIDEO TUTORIALS