user6451494
user6451494

Reputation:

No response from Bot

I am trying to write a command for my telegram bot. however I am not getting a response. Where could I be making a mistake. Below is the code. I am using the node-api.

'use strict'

var tg = require('telegram-node-bot')('mytoken')

tg.router.
    when(['/start'], 'StartController')

tg.controller('StartController', ($) => {
    tg.for('/start', () => {
        tg.sendMessage('Hi, welcome to my bot!')
    })
}) 

Upvotes: 0

Views: 715

Answers (1)

Mohamed Sohail
Mohamed Sohail

Reputation: 1867

It seems you are not passing the chat_id parameter in the sendMessage method. An easier method would be to substitute the tg variable with a $. This automatically passes in the chat_id. See correction below.

'use strict'

var tg = require('telegram-node-bot')('mytoken')

tg.router.
    when(['/start'], 'StartController')

tg.controller('StartController', ($) => {
    tg.for('/start', () => {
        $.sendMessage('Hi, welcome to my bot!') //notice the dollar sign
    })
}) 

Upvotes: 3

Related Questions