Code Monkey home page Code Monkey logo

auto-gpt-telegram-plugin's Introduction

Disclaimer!

This plugin became a first party plugin and can now be found at the official plugin repo: https://github.com/Significant-Gravitas/Auto-GPT-Plugins

Needless to say, I will still work on this plugin, but will try to prioritize the first party one at https://github.com/Significant-Gravitas/Auto-GPT-Plugins

Thank you all for using, feel free to apply PR's there! :)

Telegram Plugin for Auto-GPT

A smoothly working Telegram bot that gives you all the messages you would normally get through the Terminal. Making Auto-GPT a more user-friendly application to interact with.

SETUP

First setup a telegram bot by following the instructions here: https://core.telegram.org/bots#6-botfather

Then set the following variables in your .env:

TELEGRAM_API_KEY=your-telegram-bot-token
TELEGRAM_CHAT_ID=your-telegram-bot-chat-id

ALLOWLISTED_PLUGINS=AutoGPTTelegram
CHAT_MESSAGES_ENABLED=True

within your .env file. Also keep in mind to use the official documentation on how to use plugins.

to obtain your chat id, send a message to your bot and then use the following command:

curl https://api.telegram.org/bot{your-telegram-bot-token}/getUpdates

Running Auto-GPT with this plugin

To run this plugin, zip this repo and put it under Auto-GPT/plugins/ To run it, add the following to your start command:

For non docker:
python -m autogpt --install-plugin-deps

For Docker:
docker-compose run --rm auto-gpt --install-plugin-deps

Auto-GPT-Plugins

Plugins for Auto-GPT

Clone this repo into the plugins direcory of Auto-GPT

For interactionless use, set ALLOWLISTED_PLUGINS=example-plugin1,example-plugin2,example-plugin3 in your .env

Plugin Description
Telegram AutoGPT is capable of asking/prompting the user via a Telegram Chat bot and also responds to commands and messages.

auto-gpt-telegram-plugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

auto-gpt-telegram-plugin's Issues

Message error and autogpt close

Hello i got this message :

Waiting for response on Telegram chat...
Sending message to Telegram..
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<TelegramUtils._send_message() done, defined at plugins\Auto-GPT-Telegram.zip\Auto-GPT-Telegram-Plugin-master\src\telegram_plugin\telegram_chat.py:97> exception=TypeError("object list can't be used in 'await' expression")>
Traceback (most recent call last):
File "plugins\Auto-GPT-Telegram.zip\Auto-GPT-Telegram-Plugin-master\src\telegram_plugin\telegram_chat.py", line 101, in _send_message
bot = await self.get_bot(self)
File "plugins\Auto-GPT-Telegram.zip\Auto-GPT-Telegram-Plugin-master\src\telegram_plugin\telegram_chat.py", line 59, in get_bot
commands = await bot.get_my_commands()
TypeError: object list can't be used in 'await' expression
Traceback (most recent call last):
File "C:\Users\Snyhe\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Snyhe\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "C:\Users\Snyhe\Desktop\Nouveau dossier\Auto-GPT\autogpt_main
.py", line 5, in
autogpt.cli.main()
File "C:\Users\Snyhe\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1130, in call
return self.main(*args, **kwargs)
File "C:\Users\Snyhe\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
File "C:\Users\Snyhe\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1635, in invoke
rv = super().invoke(ctx)
File "C:\Users\Snyhe\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\Snyhe\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 760, in invoke
return _callback(*args, **kwargs)
File "C:\Users\Snyhe\AppData\Local\Programs\Python\Python310\lib\site-packages\click\decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "C:\Users\Snyhe\Desktop\Nouveau dossier\Auto-GPT\autogpt\cli.py", line 90, in main
run_auto_gpt(
File "C:\Users\Snyhe\Desktop\Nouveau dossier\Auto-GPT\autogpt\main.py", line 135, in run_auto_gpt
ai_config = construct_main_ai_config()
File "C:\Users\Snyhe\Desktop\Nouveau dossier\Auto-GPT\autogpt\prompts\prompt.py", line 105, in construct_main_ai_config
should_continue = clean_input(
File "C:\Users\Snyhe\Desktop\Nouveau dossier\Auto-GPT\autogpt\utils.py", line 29, in clean_input
plugin_response = plugin.user_input(user_input=prompt)
File "plugins\Auto-GPT-Telegram.zip\Auto-GPT-Telegram-Plugin-master\src\telegram_plugin_init
.py", line 260, in user_input
File "plugins\Auto-GPT-Telegram.zip\Auto-GPT-Telegram-Plugin-master\src\telegram_plugin\telegram_chat.py", line 193, in ask_user
File "C:\Users\Snyhe\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\Snyhe\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 649, in run_until_complete
return future.result()
File "plugins\Auto-GPT-Telegram.zip\Auto-GPT-Telegram-Plugin-master\src\telegram_plugin\telegram_chat.py", line 116, in ask_user_async
File "plugins\Auto-GPT-Telegram.zip\Auto-GPT-Telegram-Plugin-master\src\telegram_plugin\telegram_chat.py", line 159, in _poll_updates
File "plugins\Auto-GPT-Telegram.zip\Auto-GPT-Telegram-Plugin-master\src\telegram_plugin\telegram_chat.py", line 59, in get_bot
TypeError: object list can't be used in 'await' expression

message is too long

NEXT ACTION:  COMMAND = google ARGUMENTS = {'query': 'lista de los 15 virreyes y de cuando a cuando gobernaron'}

 Confirm: /yes     Decline: /no

-=-=-=-=-=-=-= COMMAND AUTHORISED BY USER -=-=-=-=-=-=-= 

Sending message to Telegram.. 

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/app/autogpt/__main__.py", line 5, in <module>
    autogpt.cli.main()
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1635, in invoke
    rv = super().invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/app/autogpt/cli.py", line 90, in main
    run_auto_gpt(
  File "/app/autogpt/main.py", line 157, in run_auto_gpt
    agent.start_interaction_loop()
  File "/app/autogpt/agent/agent.py", line 247, in start_interaction_loop
    logger.typewriter_log("SYSTEM: ", Fore.YELLOW, result)
  File "/app/autogpt/logs.py", line 87, in typewriter_log
    plugin.report(f"{title}. {content}")
  File "plugins/Auto-GPT-Telegram.zip/Auto-GPT-Telegram-Plugin-master/src/telegram_plugin/__init__.py", line 268, in report
  File "plugins/Auto-GPT-Telegram.zip/Auto-GPT-Telegram-Plugin-master/src/telegram_plugin/telegram_chat.py", line 85, in send_message
  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "plugins/Auto-GPT-Telegram.zip/Auto-GPT-Telegram-Plugin-master/src/telegram_plugin/telegram_chat.py", line 101, in _send_message
  File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 368, in decorator
    result = await func(*args, **kwargs)  # skipcq: PYL-E1102
  File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 797, in send_message
    return await self._send_message(
  File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 549, in _send_message
    result = await self._post(
  File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 456, in _post
    return await self._do_post(
  File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 487, in _do_post
    return await request.post(
  File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 165, in post
    result = await self._request_wrapper(
  File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 328, in _request_wrapper
    raise BadRequest(message)
telegram.error.BadRequest: Message is too long

Can't read .env from Docker

Hello! Thank you for your excellent work!

I am using Telegram plugin from Docker, Windows.
I got the error:

  File "plugins/Auto-GPT-Telegram-Plugin-master.zip/Auto-GPT-Telegram-Plugin-master/src/telegram_plugin/__init__.py", line 15, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/app/.env'

Every time I started AutoGPT, I had to "docker cp" .env file to the running Docker container. I used https://github.com/ppetermann/Auto-GPT-DockerSetup to prepare Docker.

I can't understand where is the issue - the way how .env is read or the Docker itself..

How can we make a reset ability ?

Hi,

its work verry well but ı want to reset in sometimes. We must to add an /reset function and if you give me some ideas i can send a pr.

Best regards,

How to actually get it to run?

Sorry if this is the wrong place to post this; I don't know a lot about this stuff.

I've got the plugin's .zip in the proper plugins folder. I added the Telegram bot's API key and the Chat ID (which was hard to find for a private chat vs a group, but I found one that works with other curl commands like sendmessage so I assume it's the right one) to the env file as well as the ALLOWLISTED_PLUGINS and CHAT_MESSAGES_ENABLED lines. I've installed all the things in requirements.txt.

So... What do I do now? When I run AutoGPT I do not get any messages through the Telegram bot. What am I doing wrong?

How to use Q/A

How do I communicate with the bot via telegram on my mobile? I have the telegram plugin cloned and zipped and have added the info to my .env I just cant figure out how to communicate with it

feature suggestion: continuous mode with step count

As I use this plugin to interact with Auto GPT remotely, which I imagine is a typical scenario. It would be great to extend the /yes command to support continuous mode for a certain number of steps as the command line supports

/start does not start an Auto-GPT instance

There are no errors and everything else works flawless so far and as intended (your Plugin is awesome btw!!!).
It seems to me that if the autogpt process is ended, it ends ALL tasks connected to it.
Since the /start option is given in the first place, I would expect the telegram bot to have an
"always on" Deamon or seomething permanently running in the background listening to /start commands,
then firing up autogpt if the command is detected.

maybe i am doing something wrong?

ImportError: cannot import name 'Bot' from 'telegram'

C:\Users\Manuel\Desktop\GPT\Auto-GPT>run.bat
All packages are installed.
NEWS: Welcome to Auto-GPT!
NEWS: Below you'll find the latest Auto-GPT News and updates regarding features!
NEWS: If you don't wish to see this message, you can run Auto-GPT with the --skip-news flag.
NEWS:
NEWS: Website and Documentation Site 📰📖
NEWS: Check out https://agpt.co, the official news & updates site for Auto-GPT!
NEWS: The documentation also has a place here, at https://docs.agpt.co
NEWS:
NEWS: 🚀 v0.3.0 Release 🚀
NEWS: Over a week and 275 pull requests have passed since v0.2.2, and we are happy to announce
NEWS: the release of v0.3.0! From now on, we will be focusing on major improvements rather
NEWS: than bugfixes, as we feel stability has reached a reasonable level. Most remaining
NEWS: issues relate to limitations in prompt generation and the memory system, which will be
NEWS: the focus of our efforts for the next release.
NEWS:
NEWS: Highlights and notable changes in this release:
NEWS:
NEWS: Plugin support 🔌
NEWS: Auto-GPT now has support for plugins! With plugins, you can extend Auto-GPT's abilities,
NEWS: adding support for third-party services and more.
NEWS: See https://github.com/Significant-Gravitas/Auto-GPT-Plugins for instructions and available plugins.
NEWS:
NEWS: Changes to Docker configuration 🐋
NEWS: The workdir has been changed from /home/appuser to /app.
NEWS: Be sure to update any volume mounts accordingly!
NEWS:
NEWS: ⚠️ Command send_tweet is DEPRECATED, and will be removed in v0.4.0 ⚠️
NEWS: Twitter functionality (and more) is now covered by plugins, see [Plugin support 🔌]
NEWS:
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "C:\Users\Manuel\Desktop\GPT\Auto-GPT\autogpt_main
.py", line 5, in
autogpt.cli.main()
File "C:\Users\Manuel\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1130, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Manuel\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Users\Manuel\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1635, in invoke
rv = super().invoke(ctx)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\Manuel\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Manuel\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 760, in invoke
return callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Manuel\AppData\Roaming\Python\Python311\site-packages\click\decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Manuel\Desktop\GPT\Auto-GPT\autogpt\cli.py", line 90, in main
run_auto_gpt(
File "C:\Users\Manuel\Desktop\GPT\Auto-GPT\autogpt\main.py", line 118, in run_auto_gpt
cfg.set_plugins(scan_plugins(cfg, cfg.debug_mode))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Manuel\Desktop\GPT\Auto-GPT\autogpt\plugins.py", line 219, in scan_plugins
zipped_module = zipped_package.load_module(str(module.parent))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 301, in load_module
File "plugins\Auto-GPT-Telegram-Plugin-master.zip\Auto-GPT-Telegram-Plugin-master\src\telegram_plugin_init
.py", line 11, in
File "plugins\Auto-GPT-Telegram-Plugin-master.zip\Auto-GPT-Telegram-Plugin-master\src\telegram_plugin\telegram_chat.py", line 4, in
ImportError: cannot import name 'Bot' from 'telegram' (C:\Users\Manuel\AppData\Roaming\Python\Python311\site-packages\telegram_init
.py)
Drücken Sie eine beliebige Taste . . .

Error when run in docker

  File "plugins/Auto-GPT-Telegram-Plugin.zip/src/telegram_plugin/__init__.py", line 10, in <module>
  File "plugins/Auto-GPT-Telegram-Plugin.zip/src/telegram_plugin/telegram_chat.py", line 4, in <module>
ModuleNotFoundError: No module named 'telegram'

docker was run via:

docker compose run --rm auto-gpt --install-plugin-deps

it seems that --install-plugin-deps not compatible with plugin

image

feature suggestion: possibility to have a command to reload AutoGpt with a new ai-settings.yml ?

Love this work! Thank you!

I think it would be very useful to have the bot be able to change the central goals of the autoGPT instance.

I have an instance running on a server, and having telegram access is really nice to have when I'm out of the house and something may come to mind to have AutoGPT work on and come home to freshly baked completed tasks.

I'm not sure how this would be achieved with AutoGPT in int's current form, but I expect a lot of architecture changes are in the pipeline.

Use callbackquery handler instead of command

I would like to suggest some improvement.
Instead of using /yes /no command you can add a replymarkup to the message so the user just click the button instead.
More esthetic and also more suitable for chat based message.

Some improvement can be made also for formating the messages because AutoGPT send a lot of messages.

I am happy to send a pull request if you find them useful. Put a thumbs up if you agree.

Thanks.

How to use

Hi, thanks for making this plugin, just not sure how to get it up and running.
The steps I have tried are:

  • checked out most recent commit of autogpt master
  • cloned this telegram plugin repo in the autogpt plugins folder
  • Added the following to my .env
ALLOWLISTED_PLUGINS=Telegram

CHAT_MESSAGES_ENABLED=True
TELEGRAM_API_KEY="*******************************************"
TELEGRAM_CHAT_ID=************

Run using the following command
docker compose run --build --rm auto-gpt

Do I need to run it differently?

Also not sure if anyone knows how to run it in debug mode using docker compose?

If I can get it running, Im happy to put up a pr to improve instructions

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.