Botframework - Bot working properly with Emulator but nothing with any published channel

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.

Botframework Test window

Skype. Bot apparently Online and properly registred

However, when I connect to my remote server using the Emulator everything works...!

Working with Emulator

What I have done:

PS: Don't mind my MS Paint skills.

PS2: Here's my code https://github.com/assimoes/chatobot

Upvotes: 2

Views: 197

Answers (1)

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!

UPDATE

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

Related Questions