telegram-bot-template icon indicating copy to clipboard operation
telegram-bot-template copied to clipboard

fix(app): made changes for deploying to vercel

Open semklim opened this issue 1 year ago • 5 comments

Changes

  • Added dotenv for Vercel deployment configuration
  • Added ping-pong command functionality:
    • /ping command and text msg ping now respond with "pong"
  • Added Ukrainian (uk) localization with translations for all commands and messages
  • Createed [src/bot/handlers/commands/command-definitions.ts] to simplify adding new commands.
  • Updated [src/bot/handlers/commands/setcommands.ts]

Link to the working bot @grammy_vercel_bot

how it work

semklim avatar Dec 22 '24 20:12 semklim

@semklim Hi, I used your commit to make it work, but get error in vercel logs. Not sure what's wrong here

Error: Invalid config
    at createConfigFromEnvironment (file:///var/task/build/src/config.js:62:15)
    at file:///var/task/build/src/config.js:67:16
    ... 2 lines matching cause stack trace ...
    at async d (/opt/rust/nodejs.js:16:18009) {
  [cause]: ValiError: Invalid type: Expected string but received undefined
      at Module.parse (file:///var/task/node_modules/valibot/dist/index.js:5219:11)
      at createConfig (file:///var/task/build/src/config.js:53:14)
      at createConfigFromEnvironment (file:///var/task/build/src/config.js:58:24)
      at file:///var/task/build/src/config.js:67:16
      at ModuleJob.run (node:internal/modules/esm/module_job:268:25)
      at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:543:26)
      at async d (/opt/rust/nodejs.js:16:18009) {
    issues: [ [Object] ]
  }
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.

m0sviatoslav avatar Jan 24 '25 13:01 m0sviatoslav

[cause]: ValiError: Invalid type: Expected string but received undefined

I going to check localy your problem, but please check your .env file. I think you forgot to add the variable(s).

Here’s my .env file that worked on Vercel: image

semklim avatar Jan 24 '25 14:01 semklim

@m0sviatoslav

I allready try it on my local machine and all works. Try this .env.

BOT_TOKEN=
BOT_MODE=polling
LOG_LEVEL=debug
DEBUG=true
BOT_WEBHOOK=https://www.example.com/webhook
BOT_WEBHOOK_SECRET="super-secret-key"
SERVER_HOST=localhost
SERVER_PORT=3000
BOT_ADMINS=[1]

semklim avatar Jan 24 '25 14:01 semklim

@semklim thank you!

m0sviatoslav avatar Jan 24 '25 20:01 m0sviatoslav

@m0sviatoslav, I also found where the problem was. Problem with the vercel Sensitive flag. I am going to correct the readme.

semklim avatar Jan 24 '25 20:01 semklim