Postback - Telegram

Hi, Botpress community.

I am creating a chat bot that has a carousel in its flow, using the “Postback” action button, the test site works fine. But when I try it on telegram, it shows the options perfectly, but when I select one of them it throws the following error:

TypeError: Cannot read property 'text' of undefined
      at sendEvent (C:\projetos\chatbot\botpress\modules\.cache\module__3bb6ffa2350d170a0d2073628288d0c6f6bdd90373dad1cc186cdd4f122a744c\dist\backend\client.js:33:26)
      at client.on (C:\projetos\chatbot\botpress\modules\.cache\module__3bb6ffa2350d170a0d2073628288d0c6f6bdd90373dad1cc186cdd4f122a744c\dist\backend\client.js:65:50)
      at Promise.resolve.then (C:\projetos\chatbot\botpress\modules\.cache\module__3bb6ffa2350d170a0d2073628288d0c6f6bdd90373dad1cc186cdd4f122a744c\node_production_modules\telegraf\composer.js:143:56)
      at tryCatcher (C:\node_modules\bluebird\js\release\util.js:16:23)
      at Promise._settlePromiseFromHandler (C:\node_modules\bluebird\js\release\promise.js:512:31)
      at Promise._settlePromise (C:\node_modules\bluebird\js\release\promise.js:569:18)
      at Promise._settlePromise0 (C:\node_modules\bluebird\js\release\promise.js:614:10)
      at Promise._settlePromises (C:\node_modules\bluebird\js\release\promise.js:694:18)
      at _drainQueueStep (C:\node_modules\bluebird\js\release\async.js:138:12)
      at _drainQueue (C:\node_modules\bluebird\js\release\async.js:131:9)
      at Async._drainQueues (C:\node_modules\bluebird\js\release\async.js:147:5)
      at Immediate.Async.drainQueues (C:\node_modules\bluebird\js\release\async.js:17:14)
      at runCallback (timers.js:696:18)
      at tryOnImmediate (timers.js:667:5)
      at processImmediate (timers.js:649:5)
      at process.topLevelDomainCallback (domain.js:121:23)

Failed to process updates. TypeError: Cannot read property 'text' of undefined
    at sendEvent (C:\projetos\chatbot\botpress\modules\.cache\module__3bb6ffa2350d170a0d2073628288d0c6f6bdd90373dad1cc186cdd4f122a744c\dist\backend\client.js:33:26)
    at client.on (C:\projetos\chatbot\botpress\modules\.cache\module__3bb6ffa2350d170a0d2073628288d0c6f6bdd90373dad1cc186cdd4f122a744c\dist\backend\client.js:65:50)
    at Promise.resolve.then (C:\projetos\chatbot\botpress\modules\.cache\module__3bb6ffa2350d170a0d2073628288d0c6f6bdd90373dad1cc186cdd4f122a744c\node_production_modules\telegraf\composer.js:143:56)
    at tryCatcher (C:\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\node_modules\bluebird\js\release\promise.js:512:31)
    at Promise._settlePromise (C:\node_modules\bluebird\js\release\promise.js:569:18)
    at Promise._settlePromise0 (C:\node_modules\bluebird\js\release\promise.js:614:10)
    at Promise._settlePromises (C:\node_modules\bluebird\js\release\promise.js:694:18)
    at _drainQueueStep (C:\node_modules\bluebird\js\release\async.js:138:12)
    at _drainQueue (C:\node_modules\bluebird\js\release\async.js:131:9)
    at Async._drainQueues (C:\node_modules\bluebird\js\release\async.js:147:5)
    at Immediate.Async.drainQueues (C:\node_modules\bluebird\js\release\async.js:17:14)
    at runCallback (timers.js:696:18)
    at tryOnImmediate (timers.js:667:5)
    at processImmediate (timers.js:649:5)
    at process.topLevelDomainCallback (domain.js:121:23)

My question is Telegram does not support the use of “Postback” in the carousel?
I am using version 12.6.0
I would appreciate any help in that regard

1 Like

Hi @novata,

I could reproduce the issue, I’ll be opening one on GitHub shortly.

This error come from here “ctx.message” Property in the sendEvent function . when you click on the button of postback you should receive the “ctx.callbackQuery” Property instead of “ctx.message”.

Solution: follow your URL (\dist\backend\client.js:33:26)
call “ctx.callbackQuery” when you click postback and “ctx.message” when you typing.

property ‘text’ just exist in ctx.message and property ‘data’ in ctx.callbackQuery

Like the below image! hope it can help!

1 Like