Reputation: 981
I've been tinkering around with the nodejs
bot framework. I was sucessfuly able to create a bot that sends proactive messages but it just so happens that it is only working with the emulator
.
It works on my local server and also on my remote server at https://chatobot.ngrok.io/api/messages
So far so good.
However, after going through the registration process at https://dev.botframework.com and "sucessfuly" publish it at the Skype Channel and Telegram channel, nothing happens. The bot won't reply and nothing is hitting my server's endpoint.
I've used the Test
feature you find on the botframework website. It send's my message, but it seems to never reach my server. Also, as far as I can tell, it doesn't give me any error.
However, when I connect to my remote server using the Emulator
everything works...!
What I have done:
MS_APP_ID
and MS_APP_PWD
are properly set as environment variables.api
with HTTPS
using nginx
(with a self-signed certificate) and later with ngrok
(just to make sure it wasn't a problem with my own certificate).PS: Don't mind my MS Paint skills.
PS2: Here's my code https://github.com/assimoes/chatobot
Upvotes: 2
Views: 197
Reputation: 981
So, I could confirm the origin of the problem is obviously at my remote server. What happens is that if I run my server as a linux service, for some reason the endpoint is never hit...however, if I run node index.js
at the console everything works?
I will try to research more on to why this happens, but any suggestion would be highly appreciated!
So I finally figured this out. So what was happening was that I had the following systemd
configuration for my nodejs api:
#/etc/systemd/system/bot.service
[Unit]
Description=Node.js Chatobot server
[Service]
ExecStart=/usr/local/bin/node /www/chatobot/index.js
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodejs-chatobot
User=chb
Environment=NODE_ENV=development PORT=8009
[Install]
WantedBy=multi-user.target
What this meant was that when I started the service, the environment variables with my APP ID
and my APP PWD
were not accessible to the running process. To solve this issue, I just had to change the systemd
script to this:
#/etc/systemd/system/bot.service
[Unit]
Description=Node.js Chatobot server
[Service]
Environment=MS_APP_ID=<MY APP ID>
Environment=MS_APP_PWD=<MY APP PWD>
ExecStart=/usr/local/bin/node /www/chatobot/index.js
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodejs-chatobot
User=chb
Environment=NODE_ENV=development PORT=8009
[Install]
WantedBy=multi-user.target
This solved everything.
Upvotes: 0