# 把 ChatGPT 接入微信和 telegram(电报)就这么简单! **Published by:** [distracting-thoughts](https://paragraph.com/@distracting-thoughts/) **Published on:** 2023-11-07 **URL:** https://paragraph.com/@distracting-thoughts/chatgpt-telegram-2 ## Content 第1步:获取自己 ChatGPT 的 apikey 【获取地址】 登入后即可获取 第2步:安装VPS 【购买地址】首冲20美金,可以免费获得100美金的使用额度 第3步:登入自己的VPS,SSH【客户端下载】 【重要提醒】:如果你对Linux系统的命令不是很清除,那么请严格按照的我的教程来操作,系统一样选择 Debian 【视频教程】 登入以后先执行环境安装命令:sudo apt-get install git sudo apt-get install golang A.把ChatGPT接入到微信上获取项目$ git clone https://github.com/ZYallers/chatgpt_wechat_robot.git进入项目目录$ cd chatgpt_wechat_robot复制配置文件$ cp config.dev.json config.json启动项目$ go run main.goB.把ChatGPT接入到Telegram (电报)上1.在电报上搜索 **BotFather ,**如图第一个。点击BotFather后,在对话框下方点击开始与BotFather对话 点击命令 /newbot 按照引导依次输入。 机器人昵称:ChatGPT-LD 机器人用户名:chatgpt_ld_bot (必须_bot结尾) 最后回复内容是机器人创建成功!红框内的字符串为该机器人的Token(重要信息不能轻易泄露给别人)。 2.然后回到自己的VPS上执行安装nodejs命令:curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install nodejs 3.安装pm2守护进程,一会要用到npm install pm2 -g 4.然后下载并安装接入的机器人git clone https://github.com/harshitethic/chatgpt-bot-telegram.git cd chatgpt-bot-telegram npm install 5.复制一个.env文件,然后修改配置文件。注意:编辑文件的时候请使用Notepad++或者Editplus ,否则可能会造成编码出错.env 直接编辑 .env 文件 API = 就是你在openAI官网上生成的apikey TG_API = 就是telegram机器人生成的token 5.保存好配置文件后,启动执行下方的启动命令,就可以和机器人聊天了!pm2 start index.js 大功告成! C.最后提醒下的是,如果需要在后台守护进程运行 那么只需运行下面命令apt-get install screen screen -S chatgpt 运行以后再运行之前的命令就可以了, 启动成功后,按Ctrl +A+D 即可挂起后台服务。 想看运行情况 screen -R chatgpt 就可以查看了~ 这样即使你断开VPS,机器人也会在后台运行。 具体的设置教程: ## Publication Information - [distracting-thoughts](https://paragraph.com/@distracting-thoughts/): Publication homepage - [All Posts](https://paragraph.com/@distracting-thoughts/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@distracting-thoughts): Subscribe to updates - [Twitter](https://twitter.com/DistractingD): Follow on Twitter