Coder Social home page Coder Social logo

ttxz / flask-chatgpt-telegrambot-vercel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pyfbsdk59/flask-chatgpt-telegrambot-vercel

1.0 0.0 1.0 1.55 MB

一個Flask ChatGPT TelegramBot快速建置於平台Vercel。

Home Page: https://flask-chat-gpt-telegram-bot-vercel-ttxz.vercel.app

Python 100.00%

flask-chatgpt-telegrambot-vercel's Introduction

Flask-ChatGPT-TelegramBot-Vercel

一個使用Flask框架和GPT3模型官方API,創造一個TelegramBot,快速建置於平台Vercel。

0. 程式猿影音教學參考。請支持且訂閱加按讚感謝他的辛勞。

https://www.youtube.com/watch?v=eKKEa6NhCd0

1. 本專案參考了以下前輩的方案改成製作,只針對剛學習Flask的朋友來佈置TelegramBot在Vercel上:

https://github.com/howarder3/GPT-Linebot-python-flask-on-vercel

https://github.com/zaoldyeck/telegram-innovation-chatbot/tree/basic

2. 本專案因部屬在Vercel上,所以程式碼和Docker版本不同,也必須使用Flask和設定webhook。設定webhook請參考。

https://zaoldyeck.medium.com/%E6%89%8B%E6%8A%8A%E6%89%8B%E6%95%99%E4%BD%A0%E6%80%8E%E9%BA%BC%E6%89%93%E9%80%A0-telegram-bot-a7b539c3402a

3. 註冊Vercel帳號後,import已經fork過來的本專案。

4. 必須在Vercel的Environment Variables設定兩個環境變數,分別是OPENAI_API_KEY和TELEGRAM_BOT_TOKEN。順便記下Vercel給的網址,可以自己縮短一些。

5. 打開瀏覽器,輸入以下網址,設定webhook為部屬完Vercel的最後步驟,格式為:https://api.telegram.org/bot{$token}/setWebhook?url={$webhook_url}。

故實際範例就像以下範例(非直接複製使用,請改用自己的telegram token和Vercel專案的URL):

https://api.telegram.org/bot606248605:AAGv_TOJdNNMc_v3toHK_X6M-dev_1tG-JA/setWebhook?url=https://xxx.vercel.app/callback

6. 成功後會顯示以下文字:

{ ok: true, result: true, description: "Webhook was set" }

創建Telegram機器人和取得token,請參考:

https://ithelp.ithome.com.tw/articles/10245264

https://tcsky.cc/tips-01-telegram-chatbot/

调试时的参考资料

  1. vercel部署参考:

flask-chatgpt-telegrambot-vercel's People

Contributors

pyfbsdk59 avatar ttxz0523 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.