ASP.NET Using C#
ASP.NET Sample Code Using C#
Submitted by One of our Customer based in Singapore , we dont offer any support on this code
1
using System.Collections.Generic;
2
using System.Web;
3
using System.Web.Http;
4
5
namespace WebApplication1.Controllers
6
{
7
public class ValuesController :
8
{
9
// GET api/values
10
public IHttpActionResult Get()
11
{
12
13
/* Mobile number with country code from the message came,
14
* if the sender mobile number is saved in the phone contacts then instead of number the contact name will come here as number.
15
* For Whatsapp Group the number will be Group Name @Sender Name / Number */
16
17
var mobileNumber = HttpContext.Current.Request["number"] ?? "0";
18
/*Text message received in the application - only first 1000 characters will be pushed to the server. */
19
var message = HttpContext.Current.Request["message-in"] ?? "";
20
/*On which messaging app the message has received 1=Whatsapp Personal | 2 = Whatsapp Business */
21
var application = HttpContext.Current.Request["application"] ?? "1";
22
/*What kind of message is received , text=1, photo=2, video=3, audio=4, location=5, document=6, contact=7 */
23
var type = HttpContext.Current.Request["type"] ?? "0";
24
/*Unique id assigned by the picky assist application */
25
var uniqueid = HttpContext.Current.Request["unique-id"] ?? "0";
26
27
if (!string.IsNullOrEmpty(mobileNumber))
28
{
29
/*Reply should be in JSON format. The response parameters are :
30
1. 'message-out' - Message you need to give it as reply.
31
2. 'delay' - If you would like to give response by setting a delay then please pass the delay value
32
in “delay” variable , delay need to be set in seconds and maximum allowed delay is 3600 seconds
33
i.e delay=10 means message will send after 10 seconds
34
35
/*Giving Reply should be in JSON */
36
var data = new Dictionary<string, object> {{"message-out", "Hello Picky"}, {"delay", 0}};
37
return Ok(data);
38
39
}
40
return BadRequest("mobile number not provided");
41
}
42
43
44
}
45
}
Copied!
Last modified 2yr ago
Copy link