baptisteArno / typebot.io

šŸ’¬ Typebot is a powerful chatbot builder that you can self-host.
https://typebot.io
Other
7.54k stars 2.09k forks source link

Viewer part is not working . Couldn't Publish ERROR-Couldn't initiate the chat . #662

Closed luck-git closed 1 year ago

luck-git commented 1 year ago

I have hosted manually the typebot on node.js using nginx server and PM2 .. Builder is working smoothly but the viewer part is not working at all . I'll attach the builder and viewer .env.local files . so it will be easy to understand if i have done any mistakes in it. BUILDER .ENV.LOCAL FILE - DATABASE_URL=postgresql://typebot:typebot@localhost:5432/typebot # Make sure to change this to your own random string of 32 characters (https://docs.typebot.io/self-hosting/docker#2-add-the-required-configuration) ENCRYPTION_SECRET=eYZhjc+vW6E2+tc3EdD6k2hu2/B8xqSLJMbqCzEeLjO5DmHR7g5xlNUoKGofJL4A NEXTAUTH_URL=http://140.82.42.177:3001/ NEXT_PUBLIC_VIEWER_URL=http://140.82.42.177:3002/ # Email settings SMTP_USERNAME=## SMTP_PASSWORD=## SMTP_HOST=smtp.zoho.in SMTP_PORT=587 NEXT_PUBLIC_SMTP_FROM='Ai Therapy Notification' ## SMTP_SECURE=false DISABLE_SIGNUP=False ADMIN_EMAIL= ## DEFAULT_WORKSPACE_PLAN=PRO

VIEWER .ENV.LOCAL FILE- ENCRYPTION_SECRET=eYZhjc+vW6E2+tc3EdD6k2hu2/B8xqSLJMbqCzEeLjO5DmHR7g5xlNUoKGofJL4A #256-bits secret (can be generated here: https://www.allkeysgenerator.com/Random/Security-Encryption-Key-Generator.aspx) NEXT_PUBLIC_VIEWER_URL=https://140.82.42.177:3002/ DATABASE_URL=postgresql://typebot:typebot@localhost:5432/typebot NEXTAUTH_URL=http://140.82.42.177:3001/ SMTP_USERNAME=## SMTP_PASSWORD=## SMTP_HOST=smtp.zoho.in SMTP_PORT=587 SMTP_FROM='Ai Therapy Notification' ## SMTP_SECURE=false

baptisteArno commented 1 year ago

Can you try removing the end slash of the viewer url?

http://140.82.42.177:3002/ => http://140.82.42.177:3002

luck-git commented 1 year ago

I checked but this is same like you recommend , So this can't be the issue .... {Builder and viewer are not making connection}

baptisteArno commented 1 year ago

Have you followed this guide? https://docs.typebot.io/self-hosting/manual

You need to build the viewer like this pnpm run build:viewer

I can see that the populated env var is http://localhost:3001

CleanShot 2023-08-03 at 08 31 39@2x
luck-git commented 1 year ago

Yes i have followed the guide .. There are two options to build .. First is You can Build it together and The second is You can build them separately . And I have build them in one single command . pnpm run build:apps . So,as you say I can try to build them separately .. Could You please help me as there I have provided the configurations what should i change in it .?

baptisteArno commented 1 year ago

Can you show the output of pnpm build:apps?

luck-git commented 1 year ago

Screenshot from 2023-08-03 12-58-35 Screenshot from 2023-08-03 12-58-59

uhlhosting commented 1 year ago

I got similar error yet on caprover. I upgraded like always did until now, and everything on builder side worked. Yet viewer was giving that error. I reverted to previous version i had, works like a charm.

baptisteArno commented 1 year ago

I got similar error yet on caprover. I upgraded like always did until now, and everything on builder side worked. Yet viewer was giving that error. I reverted to previous version i had, works like a charm.

What versions are we talking about?

Screenshot from 2023-08-03 12-58-35 Screenshot from 2023-08-03 12-58-59

That really doesn't help šŸ˜‚ can you paste the entire output of pnpm build:apps no screenshot please šŸ™

luck-git commented 1 year ago

Yes sure i will paste the whole output of pnpm build:apps ... Thanks

luck-git commented 1 year ago

Yes sure i will paste the whole output of pnpm build:apps ... Thanks

I got similar error yet on caprover. I upgraded like always did until now, and everything on builder side worked. Yet viewer was giving that error. I reverted to previous version i had, works like a charm.

What version ?

luck-git commented 1 year ago

It can be the reason of s3 that it's not publishing ?

uhlhosting commented 1 year ago

I got similar error yet on caprover. I upgraded like always did until now, and everything on builder side worked. Yet viewer was giving that error. I reverted to previous version i had, works like a charm.

What versions are we talking about?

Screenshot from 2023-08-03 12-58-35 Screenshot from 2023-08-03 12-58-59

That really doesn't help šŸ˜‚ can you paste the entire output of pnpm build:apps no screenshot please šŸ™

@baptisteArno I reffered to previous version as to latest stable 2.15.2. When upgrading to latest release viewer stopped working. Now tell me again please what logs you need here is the command you mentioned pnpm with current release.

root@7d37443bdefa:/app# pnpm  build:apps

> typebot-os@2.15.2 build:apps /app
> turbo run build --filter=builder... --filter=viewer...

ā€¢ Running build
ā€¢ Remote caching disabled

No tasks were executed as part of this run.

 Tasks:    0 successful, 0 total
Cached:    0 cached, 0 total
  Time:    32ms 

Shoul I try to upgrade to 2.16.0 and run the command again?

Note this runs on caprover, all previous upgrades until 2.16.0 worked fine both for viewer and builder.

baptisteArno commented 1 year ago

When I navigate to http://140.82.42.177:3002, then in console I checked the injected public env vars:

window.__env, I see:

{VIEWER_URL: ''}

So it didn't successfully injected the variables. Are you sure that you have a apps/viewer/.env.docker file with the following content:

# Don't edit this file
NEXT_PUBLIC_VIEWER_URL=
NEXT_PUBLIC_E2E_TEST=

It should stay as is, don't edit this file.

Then check if you have a apps/viewer/.env.local with at least that variable in it:

NEXT_PUBLIC_VIEWER_URL=http://140.82.42.177:3002

Is this the case?

luck-git commented 1 year ago

When I navigate to http://140.82.42.177:3002, then in console I checked the injected public env vars:

window.__env, I see:

{VIEWER_URL: ''}

So it didn't successfully injected the variables. Are you sure that you have a apps/viewer/.env.docker file with the following content:

# Don't edit this file
NEXT_PUBLIC_VIEWER_URL=
NEXT_PUBLIC_E2E_TEST=

It should stay as is, don't edit this file.

Then check if you have a apps/viewer/.env.local with at least that variable in it:

NEXT_PUBLIC_VIEWER_URL=http://140.82.42.177:3002

Is this the case?

I have followed the directions but still it's showing "The bot you're looking for doesn't exist." .env.docker File is present with the same content you have showed and i check the variables It's set .

baptisteArno commented 1 year ago

Ok, I think the issue is due to cache.

Can you try to run: pnpm turbo run build --filter=builder... --filter=viewer... --force.

That will build the apps and bypass the cache, it will most likely fix the issue. Do you confirm?

baptisteArno commented 1 year ago

Fixed with new env variables management

seabysalt commented 12 months ago

Hey, I am facing the same issue. I just synced the fork again. Last sync was 63 days ago. The builder deployed perfectly but the viewer didn't. And when I open the viewer now for a typebot chat that I have recently updated, it tells me: "Error! Couldn't initiate the chat" - So what was the final solution? Thanks in advance!

Screenshot 2023-11-15 at 18 00 10
baptisteArno commented 12 months ago

Can you provide the server logs? There should be a clear error there.

seabysalt commented 12 months ago

expected 1" }, { "code": "invalid_literal", "expected": 1, "path": [ "groups", 18, "blocks", 0, "items", 5, "type" ], "message": "Invalid literal value, expected 1" }, { "code": "invalid_literal", "expected": 1, "path": [ "groups", 18, "blocks", 0, "items", 6, "type" ], "message": "Invalid literal value, expected 1" }, { "code": "invalid_literal", "expected": 1, "path": [ "groups", 18, "blocks", 0, "items", 7, "type" ], "message": "Invalid literal value, expected 1" }, { "code": "invalid_literal", "expected": 1, "path": [ "groups", 18, "blocks", 0, "items", 8, "type" ], "message": "Invalid literal value, expected 1" }, { "code": "invalid_literal", "expected": 1, "path": [ "groups", 18, "blocks", 0, "items", 9, "type" ], "message": "Invalid literal value, expected 1" } ] at get error [as error] (file:///var/task/node_modules/.pnpm/zod@3.21.4/node_modules/zod/lib/index.mjs:537:31) at ZodEffects.parse (file:///var/task/node_modules/.pnpm/zod@3.21.4/node_modules/zod/lib/index.mjs:636:22) at getTypebot (/var/task/apps/viewer/.next/server/pages/api/v1/[...trpc].js:4564:117) at async startSession (/var/task/apps/viewer/.next/server/pages/api/v1/[...trpc].js:4435:21) at async /var/task/apps/viewer/.next/server/pages/api/v1/[...trpc].js:3291:120 at async resolveMiddleware (file:///var/task/node_modules/.pnpm/@trpc+server@10.34.0/node_modules/@trpc/server/dist/index.mjs:416:30) at async callRecursive (file:///var/task/node_modules/.pnpm/@trpc+server@10.34.0/node_modules/@trpc/server/dist/index.mjs:452:32) at async outputMiddleware (file:///var/task/node_modules/.pnpm/@trpc+server@10.34.0/node_modules/@trpc/server/dist/index.mjs:297:24) at async callRecursive (file:///var/task/node_modules/.pnpm/@trpc+server@10.34.0/node_modules/@trpc/server/dist/index.mjs:452:32) at async callRecursive (file:///var/task/node_modules/.pnpm/@trpc+server@10.34.0/node_modules/@trpc/server/dist/index.mjs:452:32) { issues: [ [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object] ], addIssue: [Function (anonymous)], addIssues: [Function (anonymous)], errors: [ [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object] ] } }

seabysalt commented 12 months ago

And when I try to open the chat inside the builder in preview mode, I get this:

Screenshot 2023-11-15 at 18 25 29
seabysalt commented 12 months ago

and in vercel there are no logs at all because it doesn't even show me that it even tried to deploy... The only logs are for the old ones.

Screenshot 2023-11-15 at 18 23 01
uhlhosting commented 12 months ago

@seabysalt Hi, what version you had before upgrade and to what version you upgraded to?

baptisteArno commented 12 months ago

the viewer deployment failed

Can you tell us what are the deployment logs? What's the error message?

seabysalt commented 12 months ago

I would love to and that's what is weird. There are no logs. In vercel, I can only see the ones for the builder, which worked fine but for the viewer there is not even an error message. Also, on github, I can only see this:

<img width="932" alt="Screenshot 2023-11-16 at 13 21 14" src="https://github.com/baptis

Screenshot 2023-11-16 at 13 21 29

teArno/typebot.io/assets/50774780/260e57fa-6541-451f-9aa8-432cfda6759b">

that's why its so tough to debug for me...

seabysalt commented 12 months ago
Screenshot 2023-11-16 at 13 21 14
seabysalt commented 12 months ago

This check however seems to be failing:

Screenshot 2023-11-16 at 13 27 48
seabysalt commented 12 months ago

With this error @baptisteArno create-tag The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/

seabysalt commented 12 months ago

Maybe some helpful information: I synced the fork directly within github. I deploy it using vercel and I am using supabase as my database. Once I sync it in github, it usually automatically deploys with vercel but after syncing it this time, only the builder deployed, the viewer in github (as can be seen above) said it "failed" but once I look into the logs, there is no log showing that it even attempted to deploy. In Vercel it shows nothing and in github, the latest deployments looks as seen on the screenshots. There is only this one error for the job create tag

seabysalt commented 12 months ago

The latest version before was 2.17.2 and the version now is 2.19.0 @uhlhosting

uhlhosting commented 12 months ago

@seabysalt Thanks for that. Im just thinking it could have to do with some changes made in between these releases. So it could help @baptisteArno better to see what push broked it.

baptisteArno commented 12 months ago

Go to the Vercel deployments tab

CleanShot 2023-11-16 at 14 15 33@2x

You should see the failing deployment here, click on it and tell us what the error is šŸ˜…

seabysalt commented 12 months ago

That's what I did. That's what I mean is strange, because on the viewer it doesn't show me any deployment in the last hours. Just for the builder it shows it, see:

Screenshot 2023-11-16 at 14 21 16 Screenshot 2023-11-16 at 14 21 40
seabysalt commented 12 months ago

@baptisteArno do you understand now that I don't know what to do and why I cannot show you any logs? There is nothing, I could potentially click on and I just cannot figure out, why... What would you do?

seabysalt commented 12 months ago

For the builder, the latest deployment was 20 hours ago and for the viewer 64 days ago (see screenshots). So, there is no error but on github it says that the deployment to the viewer failed, whereas it does not say that or show any proof of it on vercel, saying there are no logs... And I cannot use any updated chats now anymore.

seabysalt commented 12 months ago

On Vercel it shows no deployment attempt for the viewer (thus, no error logs) and on github it shows this, which is why I suspect it could have something to do with this tag thing that failed. Have you encountered anything like this before?

Screenshot 2023-11-16 at 14 34 01
baptisteArno commented 12 months ago

Then that's an issue with Vercel, try to re-create the pull request or contact them if it persists

seabysalt commented 12 months ago

In case someone else encounters this one day as well:

I found the issue after all & vercel actually left a comment on a commit that it's related to the plan I am using:

"If the Vercel for Git integration is installed properly, the Vercel Bot will leave comments on your commits that indicate success or failure. These comments may not always be present on the pull request if no Deployment could be created, this occurs when pre-deployment validation fails, for example, an incorrectly formatted vercel.json file."

Thank you @baptisteArno & @uhlhosting for looking into this with me.