setup webhook
hello could someone explain to me how to settup the webhook? because the example isn't very clear to me.
everthing without the webhook works fine though.
thanks in advance
I have long trouble setting webhook, but it finally worked. step 1: get sub-domain name and server (you can use your local machine if it have "white" ip-adress), I used vps on windows server 2012. for example, consider that sub-domain is bot.yourdomain.com and ip of your server (used also for rdp connection) is 1.2.3.4
step 2 (hard) : change your domain dns A record. You can't get ssl cert to ip adres, so you have to say to DNS that your domain bot,yourdomain.com is pointing at your server 1.2.3.4. after that step you should have record like bot.yourdomain.com IN A 1.2.3.4. And test for this - if you launch IIS on your server, and visit bot.yourdomain.com with browser, you should see default IIS page.
step 3: get valid ssl certificate. I didn't want to use self-signed, so I used startssl.com and got certificate for my domain bot.yourdomain.com. There was option in "validation wizard" to check domain via special html, and in this step you definitely need IIS (tune it to display static website, not very hard) - so that page http://bot.yourdomain.com/specialStartSllHtml.html should exist and open in your browser. This step may be simplier if you use self-signed certificate, but i didn't try - i wanted cool valid certificate)
step 4. tune netssh as said in Program.cs to 8443 port. get your cert thumbprint from your cert, and your app guid in AssemblyInfo.cs.
step 5 (important): tune firewall. by defaults, firewall on win server blocks 8443 port. and you should allow webhook EXE app thru firewall.
step 6. for test you can implement GET method, to check that all works like that:
// test get method. usage: https://bot.yourdomain.com:8443/WebHook?value=1234
[HttpGet]
public IHttpActionResult Get([FromUri] string value)
{
var message = value;
Console.WriteLine("Received GET Message type {0} ToString={1} ", message.GetType().ToString(), message.ToString());
return Ok();
}
webhook shoul look like:
Bot.Api.SetWebhook("https://bot.yourdomain.com:8443/WebHook").Wait();
If webhook is working, you should see 1234 in Console.
@MrRoundRobin maybe you should add [HttpPost] to Post method, I think it helped me:
[HttpPost]
public async Task
P.S. also PostMan app for Chrome helped me a lot in testing. Maybe this method can be simplified, if use self-signed cer, and try to start webhook on IP adress, not using sub-domain, but i didn't try
for testing you can also use ngrok so you don't need to setup the domain and ssl stuff.
Yes, ngrok is also very helpful. I tried it at first, it worked, but i also wanted my own certificate) if you use ngrok, steps 1-3 are unnecessary, you only need to tune your local machine firewall and use ngrok https url that it will give you. I think that you still need to tune netssh...