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

using System.Collections.Generic;
using System.Web;
using System.Web.Http;

namespace WebApplication1.Controllers
{
    public class ValuesController :
    {
        // GET api/values
        public IHttpActionResult Get()
        {

            /* Mobile number with country code from the message came, 
             * if the sender mobile number is saved in the phone contacts then instead of number the contact name will come here as number. 
             * For Whatsapp Group the number will be Group Name @Sender Name / Number  */

            var mobileNumber = HttpContext.Current.Request["number"] ?? "0";
            /*Text message received in the application - only first 1000 characters will be pushed to the server. */
            var message = HttpContext.Current.Request["message-in"] ?? "";
            /*On which messaging app the message has received 1=Whatsapp Personal | 2 = Whatsapp Business */
            var application = HttpContext.Current.Request["application"] ?? "1";
            /*What kind of message is received , text=1, photo=2, video=3, audio=4, location=5, document=6, contact=7 */
            var type = HttpContext.Current.Request["type"] ?? "0";
            /*Unique id assigned by the picky assist application */
            var uniqueid = HttpContext.Current.Request["unique-id"] ?? "0";

            if (!string.IsNullOrEmpty(mobileNumber))
            {
                /*Reply should be in JSON format. The response parameters are : 
                1. 'message-out' - Message you need to give it as reply.
                2. 'delay' - If you would like to give response by setting a delay then please pass the delay value 
                in “delay” variable , delay need to be set in seconds and maximum allowed delay is 3600 seconds 
                i.e delay=10 means message will send after 10 seconds

                /*Giving Reply should be in JSON */
                var data = new Dictionary<string, object> {{"message-out", "Hello Picky"}, {"delay", 0}};
                return Ok(data);

            }
            return BadRequest("mobile number not provided");
        }


    }
}

Last updated

#663: Prebuilt Guide Updated

Change request updated