├── .coveragerc ├── .editorconfig ├── .flake8 ├── .github └── workflows │ └── test-plugin-installation.yml ├── .gitignore ├── .isort.cfg ├── .pre-commit-config.yaml ├── .sourcery.yaml ├── LICENSE ├── Makefile ├── README.md ├── helpers.bat ├── helpers.sh ├── pylintrc ├── pyproject.toml ├── requirements.txt ├── run_pylint.py └── src └── AutoGPT_IFTTT ├── __init__.py ├── ifttt.py └── ifttt_test.py /.coveragerc: -------------------------------------------------------------------------------- 1 | [coverage:run] 2 | branch = True 3 | plugins = 4 | omit = 5 | # omit anything in a .local directory anywhere 6 | */.local/* 7 | 8 | [run] 9 | branch = True 10 | plugins = 11 | omit = 12 | # omit anything in a .local directory anywhere 13 | */.local/* 14 | 15 | [paths] 16 | source = . 17 | 18 | 19 | [report] 20 | # Regexes for lines to exclude from consideration 21 | 22 | omit = 23 | # omit anything in a .local directory anywhere 24 | */.local/* 25 | 26 | exclude_lines = 27 | # Have to re-enable the standard pragma 28 | pragma: no cover 29 | # Don't complain about missing debug-only code: 30 | def __repr__ 31 | if self\.debug 32 | 33 | # Don't complain if tests don't hit defensive assertion code: 34 | raise AssertionError 35 | raise NotImplementedError 36 | 37 | # Don't complain if non-runnable code isn't run: 38 | if 0: 39 | if __name__ == .__main__.: 40 | 41 | # Don't complain about abstract methods, they aren't run: 42 | @(abc\.)?abstractmethod 43 | 44 | ignore_errors = True 45 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Top-most EditorConfig file 2 | root = true 3 | 4 | # Set default charset 5 | [*] 6 | charset = utf-8 7 | 8 | # Use black formatter for python files 9 | [*.py] 10 | profile = black 11 | 12 | # Set defaults for windows and batch filess 13 | [*.bat] 14 | end_of_line = crlf 15 | indent_style = space 16 | indent_size = 2 17 | 18 | # Set defaults for shell scripts 19 | [*.sh] 20 | end_of_line = lf 21 | trim_trailing_whitespace = true 22 | insert_final_newline = false 23 | 24 | # Set defaults for Makefiles 25 | [Makefile] 26 | end_of_line = lf 27 | indent_style = tab 28 | indent_size = 4 29 | trim_trailing_whitespace = true 30 | insert_final_newline = true -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 88 3 | extend-ignore = E203 4 | exclude = 5 | .tox, 6 | __pycache__, 7 | *.pyc, 8 | .env 9 | venv/* 10 | .venv/* 11 | reports/* 12 | dist/* 13 | -------------------------------------------------------------------------------- /.github/workflows/test-plugin-installation.yml: -------------------------------------------------------------------------------- 1 | name: Test installation of plugin against the PR 2 | on: 3 | push: 4 | branches: [ master ] 5 | pull_request: 6 | branches: [ master ] 7 | 8 | jobs: 9 | test-plugin-installation: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Install Kurtosis 13 | run: | 14 | echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list 15 | sudo apt update 16 | sudo apt install kurtosis-cli 17 | - name: Install plugins 18 | run: | 19 | set -euo pipefail 20 | kurtosis run github.com/kurtosis-tech/autogpt-package '{"OPENAI_API_KEY": "test", "ALLOWLISTED_PLUGINS": "AutoGPT_IFTTT", "__plugin_branch_to_use": '\"${{ github.head_ref}}\"', "__plugin_repo_to_use":'\"${{ github.event.pull_request.head.repo.full_name }}\"'}' 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | ./builds 132 | ./vs -------------------------------------------------------------------------------- /.isort.cfg: -------------------------------------------------------------------------------- 1 | [settings] 2 | profile = black 3 | multi_line_output = 3 4 | include_trailing_comma = true 5 | force_grid_wrap = 0 6 | use_parentheses = true 7 | ensure_newline_before_comments = true 8 | line_length = 88 9 | sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER 10 | skip = .tox,__pycache__,*.pyc,venv*/*,reports,venv,env,node_modules,.env,.venv,dist 11 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/sourcery-ai/sourcery 3 | rev: v1.1.0 # Get the latest tag from https://github.com/sourcery-ai/sourcery/tags 4 | hooks: 5 | - id: sourcery 6 | 7 | - repo: https://github.com/pre-commit/pre-commit-hooks 8 | rev: v0.9.2 9 | hooks: 10 | - id: check-added-large-files 11 | args: [ '--maxkb=500' ] 12 | - id: check-byte-order-marker 13 | - id: check-case-conflict 14 | - id: check-merge-conflict 15 | - id: check-symlinks 16 | - id: debug-statements 17 | 18 | - repo: local 19 | hooks: 20 | - id: isort 21 | name: isort-local 22 | entry: isort 23 | language: python 24 | types: [ python ] 25 | exclude: .+/(dist|.venv|venv|build)/.+ 26 | pass_filenames: true 27 | - id: black 28 | name: black-local 29 | entry: black 30 | language: python 31 | types: [ python ] 32 | exclude: .+/(dist|.venv|venv|build)/.+ 33 | pass_filenames: true -------------------------------------------------------------------------------- /.sourcery.yaml: -------------------------------------------------------------------------------- 1 | # 🪄 This is your project's Sourcery configuration file. 2 | 3 | # You can use it to get Sourcery working in the way you want, such as 4 | # ignoring specific refactorings, skipping directories in your project, 5 | # or writing custom rules. 6 | 7 | # 📚 For a complete reference to this file, see the documentation at 8 | # https://docs.sourcery.ai/Configuration/Project-Settings/ 9 | 10 | # This file was auto-generated by Sourcery on 2023-02-25 at 21:07. 11 | 12 | version: '1' # The schema version of this config file 13 | 14 | ignore: # A list of paths or files which Sourcery will ignore. 15 | - .git 16 | - venv 17 | - .venv 18 | - build 19 | - dist 20 | - env 21 | - .env 22 | - .tox 23 | 24 | rule_settings: 25 | enable: 26 | - default 27 | - gpsg 28 | disable: [] # A list of rule IDs Sourcery will never suggest. 29 | rule_types: 30 | - refactoring 31 | - suggestion 32 | - comment 33 | python_version: '3.9' # A string specifying the lowest Python version your project supports. Sourcery will not suggest refactorings requiring a higher Python version. 34 | 35 | # rules: # A list of custom rules Sourcery will include in its analysis. 36 | # - id: no-print-statements 37 | # description: Do not use print statements in the test directory. 38 | # pattern: print(...) 39 | # language: python 40 | # replacement: 41 | # condition: 42 | # explanation: 43 | # paths: 44 | # include: 45 | # - test 46 | # exclude: 47 | # - conftest.py 48 | # tests: [] 49 | # tags: [] 50 | 51 | # rule_tags: {} # Additional rule tags. 52 | 53 | # metrics: 54 | # quality_threshold: 25.0 55 | 56 | # github: 57 | # labels: [] 58 | # ignore_labels: 59 | # - sourcery-ignore 60 | # request_review: author 61 | # sourcery_branch: sourcery/{base_branch} 62 | 63 | # clone_detection: 64 | # min_lines: 3 65 | # min_duplicates: 2 66 | # identical_clones_only: false 67 | 68 | # proxy: 69 | # url: 70 | # ssl_certs_file: 71 | # no_ssl_verify: false 72 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Toran Bruce Richards 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(OS),Windows_NT) 2 | os := win 3 | SCRIPT_EXT := .bat 4 | SHELL_CMD := cmd /C 5 | else 6 | os := nix 7 | SCRIPT_EXT := .sh 8 | SHELL_CMD := bash 9 | endif 10 | 11 | helpers = @$(SHELL_CMD) helpers$(SCRIPT_EXT) $1 12 | 13 | clean qa style: helpers$(SCRIPT_EXT) 14 | 15 | clean: 16 | $(call helpers,clean) 17 | 18 | qa: 19 | $(call helpers,qa) 20 | 21 | style: 22 | $(call helpers,style) 23 | 24 | .PHONY: clean qa style -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AutoGPT_IFTTT 2 | A webhook connector for If-This-Then-That (IFTTT) using the Auto-GPT framework. This plugin allows you to easily integrate IFTTT with the powerful language model GPT-4 to create various automations and applications. 3 | 4 | ## Table of Contents 5 | 6 | - [Prerequisites](#prerequisites) 7 | - [Plugin Installation Steps](#plugin-installation-steps) 8 | - [Connect the .ENV](#connect-the-env) 9 | - [Set up IFTTT](#set-up-ifttt) 10 | - [Processing the data](#processing-the-data) 11 | - [Testing](#testing) 12 | - [Usage](#usage) 13 | - [Troubleshooting](#troubleshooting) 14 | - [Contributing](#contributing) 15 | - [License](#license) 16 | 17 | ## Prerequisites 18 | 19 | Ensure you have the following: 20 | 21 | - Auto-GPT repository 22 | - An IFTTT account 23 | 24 | ## Plugin Installation Steps 25 | 26 | 1. **Copy the plugin's Zip file:** 27 | Place the plugin's Zip file in the `plugins` folder of the Auto-GPT repository. 28 | 29 | 2. **Allowlist the plugin (optional):** 30 | Add the plugin's class name to the `ALLOWLISTED_PLUGINS` in the `.env` file to avoid being prompted with a warning when loading the plugin: 31 | 32 | ```shell 33 | ALLOWLISTED_PLUGINS=example-plugin1,example-plugin2,example-plugin3 34 | ``` 35 | 36 | ## Connect the .ENV 37 | 38 | Add this to your .env to get AutoGPT to send to the right endpoint. 39 | 40 | ``` 41 | ################################################################################ 42 | ### AUTOGPT IFTTT Webhook Integration 43 | ################################################################################ 44 | IFTTT_WEBHOOK_TRIGGER_NAME= 45 | IFTTT_KEY= 46 | ``` 47 | 48 | ## Set up IFTTT 49 | 50 | IFTTT requires a webhooks connector. Create a new applet or modify an existing one, and add Webhooks to the applet. Set up a trigger name that you won't forget; 51 | this trigger will be how you get the call into IFTTT. Above it is your ```IFTTT_WEBHOOK_TRIGGER_NAME``` 52 | 53 | Once added, you'll have to go to the documentation button to find your specific key. The key will route your json content to you will be posting. 54 | 55 | ## Processing the data 56 | 57 | Once the first post works, you'll have a JSON value going into IFTTT. Use a JavaScript filter to make decisions about your content. 58 | 59 | In this example, if I don't have anything worth doing, don't send me an email. 60 | 61 | ```javascript 62 | let payload = JSON.parse(MakerWebhooks.jsonEvent.JsonPayload) 63 | 64 | if (payload.data != null) 65 | { 66 | let title = payload.data[0].title 67 | let summary = payload.data[0].summary 68 | let content = payload.data[0].content 69 | 70 | if (summary === "undefined") 71 | Email.sendMeEmail.skip("No content was found") 72 | else 73 | Email.sendMeEmail.setSubject(title) 74 | Email.sendMeEmail.setBody("Summary:" + summary + "\n\nContent: " + content) 75 | } 76 | else 77 | Email.sendMeEmail.skip("No data was found"); 78 | ``` 79 | 80 | ## Testing 81 | 82 | To test the integration, perform the following steps: 83 | 84 | 1. Send a sample request to AutoGPT 85 | 2. Verify that the request is received by IFTTT 86 | 3. Check the processing logic and ensure it is working as expected 87 | 88 | ## Usage 89 | 90 | After successful testing, you can start using this plugin to create various automations and applications with the help of the GPT-4 language model and IFTTT. 91 | 92 | ## Troubleshooting 93 | 94 | If you encounter any issues while using the plugin, refer to the following: 95 | 96 | - Check the `.env` file for proper configuration. 97 | - Verify that the IFTTT webhook trigger name and key are correct. 98 | - Inspect the IFTTT applet configuration and ensure it is set up properly. 99 | - Review the JavaScript filter for any syntax errors or logical issues. 100 | - Check the Auto-GPT logs for any errors or warnings related to the plugin. 101 | 102 | ## Contributing 103 | 104 | We welcome contributions to the AutoGPT_IFTTT plugin! If you would like to contribute, please follow these steps: 105 | 106 | 1. Fork the repository. 107 | 2. Create a new branch for your feature or bugfix. 108 | 3. Make your changes, ensuring they adhere to the project's coding standards and guidelines. 109 | 4. Submit a pull request with a detailed description of your changes. 110 | 111 | Please note that by contributing to this project, you agree to abide by the [Code of Conduct](CODE_OF_CONDUCT.md). 112 | -------------------------------------------------------------------------------- /helpers.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set GPT_HOME=C:\Users\anton\Auto-GPT 4 | 5 | if "%1" == "clean" ( 6 | echo Removing build artifacts and temporary files... 7 | call :clean 8 | ) else if "%1" == "qa" ( 9 | echo Running static analysis tools... 10 | call :qa 11 | ) else if "%1" == "style" ( 12 | echo Running code formatters... 13 | call :style 14 | ) else if "%1" == "package" ( 15 | echo Packaging archive... 16 | call :package 17 | ) else if "%1" == "unittest" ( 18 | echo Running tests 19 | call :unittest 20 | ) else ( 21 | echo Usage: %0 [clean^|qa^|style^|package] 22 | exit /b 1 23 | ) 24 | 25 | exit /b 0 26 | 27 | :clean 28 | rem Remove build artifacts and temporary files 29 | @del /s /q build 2>nul 30 | @del /s /q dist 2>nul 31 | @del /s /q __pycache__ 2>nul 32 | @del /s /q *.egg-info 2>nul 33 | @del /s /q **\*.egg-info 2>nul 34 | @del /s /q *.pyc 2>nul 35 | @del /s /q **\*.pyc 2>nul 36 | @del /s /q reports 2>nul 37 | echo Done! 38 | exit /b 0 39 | 40 | :qa 41 | rem Run static analysis tools 42 | @flake8 . 43 | @python run_pylint.py 44 | echo Done! 45 | exit /b 0 46 | 47 | :style 48 | rem Format code 49 | @isort . 50 | @black --exclude=".*\/*(dist|venv|.venv|test-results)\/*.*" . 51 | echo Done! 52 | exit /b 0 53 | 54 | :package 55 | python -m zipfile -c .\builds\AutoGPT_IFTTT.zip src\AutoGPT_IFTTT 56 | copy .\builds\AutoGPT_IFTTT.zip %GPT_HOME%\plugins 57 | python -m autogpt --debug 58 | exit /b 0 59 | 60 | :unittest 61 | python -m unittest src/AutoGPT_IFTTT/ifttt_test.py -v 62 | exit /b 0 -------------------------------------------------------------------------------- /helpers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | clean() { 6 | # Remove build artifacts and temporary files 7 | rm -rf {build,dist,__pycache__,*.egg-info,**/*.egg-info,*.pyc,**/*.pyc,reports} 2>/dev/null || true 8 | } 9 | 10 | qa() { 11 | # Run static analysis tools 12 | if command -v flake8 >/dev/null 2>&1; then 13 | flake8 . 14 | fi 15 | 16 | python run_pylint.py 17 | } 18 | 19 | style() { 20 | # Format code 21 | isort . 22 | black --exclude=".*/*(dist|venv|.venv|test-results)/*.*" . 23 | } 24 | 25 | case "$1" in 26 | clean) 27 | echo Removing build artifacts and temporary files... 28 | clean 29 | ;; 30 | qa) 31 | echo Running static analysis tools... 32 | qa 33 | ;; 34 | style) 35 | echo Running code formatters... 36 | style 37 | ;; 38 | *) 39 | echo "Usage: $0 [clean|qa|style]" 40 | exit 1 41 | ;; 42 | esac 43 | 44 | printf 'Done!\n\n' 45 | exit 0 -------------------------------------------------------------------------------- /pylintrc: -------------------------------------------------------------------------------- 1 | # This Pylint rcfile contains a best-effort configuration to uphold the 2 | # best-practices and style described in the Google Python style guide: 3 | # https://google.github.io/styleguide/pyguide.html 4 | # 5 | # Its canonical open-source location is: 6 | # https://google.github.io/styleguide/pylintrc 7 | 8 | [MASTER] 9 | 10 | # Files or directories to be skipped. They should be base names, not paths. 11 | ignore= 12 | 13 | # Files or directories matching the regex patterns are skipped. The regex 14 | # matches against base names, not paths. 15 | ignore-patterns= 16 | 17 | # Pickle collected data for later comparisons. 18 | persistent=no 19 | 20 | # List of plugins (as comma separated values of python modules names) to load, 21 | # usually to register additional checkers. 22 | load-plugins= 23 | 24 | # Use multiple processes to speed up Pylint. 25 | jobs=4 26 | 27 | # Allow loading of arbitrary C extensions. Extensions are imported into the 28 | # active Python interpreter and may run arbitrary code. 29 | unsafe-load-any-extension=no 30 | 31 | 32 | [MESSAGES CONTROL] 33 | 34 | ignore=*.pyc 35 | # Only show warnings with the listed confidence levels. Leave empty to show 36 | # all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED 37 | confidence= 38 | 39 | # Enable the message, report, category or checker with the given id(s). You can 40 | # either give multiple identifier separated by comma (,) or put this option 41 | # multiple time (only on the command line, not in the configuration file where 42 | # it should appear only once). See also the "--disable" option for examples. 43 | #enable= 44 | 45 | # Disable the message, report, category or checker with the given id(s). You 46 | # can either give multiple identifiers separated by comma (,) or put this 47 | # option multiple times (only on the command line, not in the configuration 48 | # file where it should appear only once).You can also use "--disable=all" to 49 | # disable everything first and then reenable specific checks. For example, if 50 | # you want to run only the similarities checker, you can use "--disable=all 51 | # --enable=similarities". If you want to run only the classes checker, but have 52 | # no Warning level messages displayed, use"--disable=all --enable=classes 53 | # --disable=W" 54 | disable=abstract-method, 55 | parse-error, 56 | apply-builtin, 57 | arguments-differ, 58 | attribute-defined-outside-init, 59 | backtick, 60 | bad-option-value, 61 | basestring-builtin, 62 | buffer-builtin, 63 | c-extension-no-member, 64 | consider-using-enumerate, 65 | cmp-builtin, 66 | cmp-method, 67 | coerce-builtin, 68 | coerce-method, 69 | delslice-method, 70 | div-method, 71 | duplicate-code, 72 | eq-without-hash, 73 | execfile-builtin, 74 | file-builtin, 75 | filter-builtin-not-iterating, 76 | fixme, 77 | getslice-method, 78 | global-statement, 79 | hex-method, 80 | idiv-method, 81 | implicit-str-concat, 82 | import-error, 83 | import-self, 84 | import-star-module-level, 85 | inconsistent-return-statements, 86 | input-builtin, 87 | intern-builtin, 88 | invalid-str-codec, 89 | locally-disabled, 90 | long-builtin, 91 | long-suffix, 92 | map-builtin-not-iterating, 93 | misplaced-comparison-constant, 94 | missing-function-docstring, 95 | metaclass-assignment, 96 | next-method-called, 97 | next-method-defined, 98 | no-absolute-import, 99 | no-else-break, 100 | no-else-continue, 101 | no-else-raise, 102 | no-else-return, 103 | no-init, # added 104 | no-member, 105 | no-name-in-module, 106 | no-self-use, 107 | nonzero-method, 108 | oct-method, 109 | old-division, 110 | old-ne-operator, 111 | old-octal-literal, 112 | old-raise-syntax, 113 | parameter-unpacking, 114 | print-statement, 115 | raising-string, 116 | range-builtin-not-iterating, 117 | raw_input-builtin, 118 | rdiv-method, 119 | reduce-builtin, 120 | relative-import, 121 | reload-builtin, 122 | round-builtin, 123 | setslice-method, 124 | signature-differs, 125 | standarderror-builtin, 126 | suppressed-message, 127 | sys-max-int, 128 | too-few-public-methods, 129 | too-many-ancestors, 130 | too-many-arguments, 131 | too-many-boolean-expressions, 132 | too-many-branches, 133 | too-many-instance-attributes, 134 | too-many-locals, 135 | too-many-nested-blocks, 136 | too-many-public-methods, 137 | too-many-return-statements, 138 | too-many-statements, 139 | trailing-newlines, 140 | unichr-builtin, 141 | unicode-builtin, 142 | unnecessary-pass, 143 | unpacking-in-except, 144 | useless-else-on-loop, 145 | useless-object-inheritance, 146 | useless-suppression, 147 | using-cmp-argument, 148 | wrong-import-order, 149 | xrange-builtin, 150 | zip-builtin-not-iterating, 151 | 152 | 153 | [REPORTS] 154 | 155 | # Set the output format. Available formats are text, parseable, colorized, msvs 156 | # (visual studio) and html. You can also give a reporter class, eg 157 | # mypackage.mymodule.MyReporterClass. 158 | output-format=text 159 | 160 | # Tells whether to display a full report or only the messages 161 | reports=no 162 | 163 | # Python expression which should return a note less than 10 (10 is the highest 164 | # note). You have access to the variables errors warning, statement which 165 | # respectively contain the number of errors / warnings messages and the total 166 | # number of statements analyzed. This is used by the global evaluation report 167 | # (RP0004). 168 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) 169 | 170 | # Template used to display messages. This is a python new-style format string 171 | # used to format the message information. See doc for all details 172 | #msg-template= 173 | 174 | 175 | [BASIC] 176 | 177 | # Good variable names which should always be accepted, separated by a comma 178 | good-names=main,_ 179 | 180 | # Bad variable names which should always be refused, separated by a comma 181 | bad-names= 182 | 183 | # Colon-delimited sets of names that determine each other's naming style when 184 | # the name regexes allow several styles. 185 | name-group= 186 | 187 | # Include a hint for the correct naming format with invalid-name 188 | include-naming-hint=no 189 | 190 | # List of decorators that produce properties, such as abc.abstractproperty. Add 191 | # to this list to register other decorators that produce valid properties. 192 | property-classes=abc.abstractproperty,cached_property.cached_property,cached_property.threaded_cached_property,cached_property.cached_property_with_ttl,cached_property.threaded_cached_property_with_ttl 193 | 194 | # Regular expression matching correct function names 195 | function-rgx=^(?:(?PsetUp|tearDown|setUpModule|tearDownModule)|(?P_?[A-Z][a-zA-Z0-9]*)|(?P_?[a-z][a-z0-9_]*))$ 196 | 197 | # Regular expression matching correct variable names 198 | variable-rgx=^[a-z][a-z0-9_]*$ 199 | 200 | # Regular expression matching correct constant names 201 | const-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$ 202 | 203 | # Regular expression matching correct attribute names 204 | attr-rgx=^_{0,2}[a-z][a-z0-9_]*$ 205 | 206 | # Regular expression matching correct argument names 207 | argument-rgx=^[a-z][a-z0-9_]*$ 208 | 209 | # Regular expression matching correct class attribute names 210 | class-attribute-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$ 211 | 212 | # Regular expression matching correct inline iteration names 213 | inlinevar-rgx=^[a-z][a-z0-9_]*$ 214 | 215 | # Regular expression matching correct class names 216 | class-rgx=^_?[A-Z][a-zA-Z0-9]*$ 217 | 218 | # Regular expression matching correct module names 219 | module-rgx=^(_?[a-z][a-z0-9_]*|__init__|__main__)$ 220 | 221 | # Regular expression matching correct method names 222 | method-rgx=(?x)^(?:(?P_[a-z0-9_]+__|runTest|setUp|tearDown|setUpTestCase|tearDownTestCase|setupSelf|tearDownClass|setUpClass|(test|assert)_*[A-Z0-9][a-zA-Z0-9_]*|next)|(?P_{0,2}[A-Z][a-zA-Z0-9_]*)|(?P_{0,2}[a-z][a-z0-9_]*))$ 223 | 224 | # Regular expression which should only match function or class names that do 225 | # not require a docstring. 226 | no-docstring-rgx=(__.*__|main|test.*|.*test|.*Test)$ 227 | 228 | # Minimum line length for functions/classes that require docstrings, shorter 229 | # ones are exempt. 230 | docstring-min-length=10 231 | 232 | 233 | [TYPECHECK] 234 | 235 | # List of decorators that produce context managers, such as 236 | # contextlib.contextmanager. Add to this list to register other decorators that 237 | # produce valid context managers. 238 | contextmanager-decorators=contextlib.contextmanager,contextlib2.contextmanager 239 | 240 | # Tells whether missing members accessed in mixin class should be ignored. A 241 | # mixin class is detected if its name ends with "mixin" (case insensitive). 242 | ignore-mixin-members=yes 243 | 244 | # List of module names for which member attributes should not be checked 245 | # (useful for modules/projects where namespaces are manipulated during runtime 246 | # and thus existing member attributes cannot be deduced by static analysis. It 247 | # supports qualified module names, as well as Unix pattern matching. 248 | ignored-modules= 249 | 250 | # List of class names for which member attributes should not be checked (useful 251 | # for classes with dynamically set attributes). This supports the use of 252 | # qualified names. 253 | ignored-classes=optparse.Values,thread._local,_thread._local 254 | 255 | # List of members which are set dynamically and missed by pylint inference 256 | # system, and so shouldn't trigger E1101 when accessed. Python regular 257 | # expressions are accepted. 258 | generated-members= 259 | 260 | 261 | [FORMAT] 262 | 263 | # Maximum number of characters on a single line. 264 | max-line-length=88 265 | 266 | # TODO(https://github.com/PyCQA/pylint/issues/3352): Direct pylint to exempt 267 | # lines made too long by directives to pytype. 268 | 269 | # Regexp for a line that is allowed to be longer than the limit. 270 | ignore-long-lines=(?x)( 271 | ^\s*(\#\ )??$| 272 | ^\s*(from\s+\S+\s+)?import\s+.+$) 273 | 274 | # Allow the body of an if to be on the same line as the test if there is no 275 | # else. 276 | single-line-if-stmt=yes 277 | 278 | # Maximum number of lines in a module 279 | max-module-lines=99999 280 | 281 | # String used as indentation unit. The internal Google style guide mandates 2 282 | # spaces. Google's externaly-published style guide says 4, consistent with 283 | # PEP 8. Here, we use 2 spaces, for conformity with many open-sourced Google 284 | # projects (like TensorFlow). 285 | indent-string=' ' 286 | 287 | # Number of spaces of indent required inside a hanging or continued line. 288 | indent-after-paren=4 289 | 290 | # Expected format of line ending, e.g. empty (any line ending), LF or CRLF. 291 | expected-line-ending-format= 292 | 293 | 294 | [MISCELLANEOUS] 295 | 296 | # List of note tags to take in consideration, separated by a comma. 297 | notes=TODO 298 | 299 | 300 | [STRING] 301 | 302 | # This flag controls whether inconsistent-quotes generates a warning when the 303 | # character used as a quote delimiter is used inconsistently within a module. 304 | check-quote-consistency=yes 305 | 306 | 307 | [VARIABLES] 308 | 309 | # Tells whether we should check for unused import in __init__ files. 310 | init-import=no 311 | 312 | # A regular expression matching the name of dummy variables (i.e. expectedly 313 | # not used). 314 | dummy-variables-rgx=^\*{0,2}(_$|unused_|dummy_) 315 | 316 | # List of additional names supposed to be defined in builtins. Remember that 317 | # you should avoid to define new builtins when possible. 318 | additional-builtins= 319 | 320 | # List of strings which can identify a callback function by name. A callback 321 | # name must start or end with one of those strings. 322 | callbacks=cb_,_cb 323 | 324 | # List of qualified module names which can have objects that can redefine 325 | # builtins. 326 | redefining-builtins-modules=six,six.moves,past.builtins,future.builtins,functools 327 | 328 | 329 | [LOGGING] 330 | 331 | # Logging modules to check that the string format arguments are in logging 332 | # function parameter format 333 | logging-modules=logging,absl.logging,tensorflow.io.logging 334 | 335 | 336 | [SIMILARITIES] 337 | 338 | # Minimum lines number of a similarity. 339 | min-similarity-lines=4 340 | 341 | # Ignore comments when computing similarities. 342 | ignore-comments=yes 343 | 344 | # Ignore docstrings when computing similarities. 345 | ignore-docstrings=yes 346 | 347 | # Ignore imports when computing similarities. 348 | ignore-imports=no 349 | 350 | 351 | [SPELLING] 352 | 353 | # Spelling dictionary name. Available dictionaries: none. To make it working 354 | # install python-enchant package. 355 | spelling-dict= 356 | 357 | # List of comma separated words that should not be checked. 358 | spelling-ignore-words= 359 | 360 | # A path to a file that contains private dictionary; one word per line. 361 | spelling-private-dict-file= 362 | 363 | # Tells whether to store unknown words to indicated private dictionary in 364 | # --spelling-private-dict-file option instead of raising a message. 365 | spelling-store-unknown-words=no 366 | 367 | 368 | [IMPORTS] 369 | 370 | # Deprecated modules which should not be used, separated by a comma 371 | deprecated-modules=regsub, 372 | TERMIOS, 373 | Bastion, 374 | rexec, 375 | sets 376 | 377 | # Create a graph of every (i.e. internal and external) dependencies in the 378 | # given file (report RP0402 must not be disabled) 379 | import-graph= 380 | 381 | # Create a graph of external dependencies in the given file (report RP0402 must 382 | # not be disabled) 383 | ext-import-graph= 384 | 385 | # Create a graph of internal dependencies in the given file (report RP0402 must 386 | # not be disabled) 387 | int-import-graph= 388 | 389 | # Force import order to recognize a module as part of the standard 390 | # compatibility libraries. 391 | known-standard-library= 392 | 393 | # Force import order to recognize a module as part of a third party library. 394 | known-third-party=enchant, absl 395 | 396 | # Analyse import fallback blocks. This can be used to support both Python 2 and 397 | # 3 compatible code, which means that the block might have code that exists 398 | # only in one or another interpreter, leading to false positives when analysed. 399 | analyse-fallback-blocks=no 400 | 401 | 402 | [CLASSES] 403 | 404 | # List of method names used to declare (i.e. assign) instance attributes. 405 | defining-attr-methods=__init__, 406 | __new__, 407 | setUp 408 | 409 | # List of member names, which should be excluded from the protected access 410 | # warning. 411 | exclude-protected=_asdict, 412 | _fields, 413 | _replace, 414 | _source, 415 | _make 416 | 417 | # List of valid names for the first argument in a class method. 418 | valid-classmethod-first-arg=cls, 419 | class_ 420 | 421 | # List of valid names for the first argument in a metaclass class method. 422 | valid-metaclass-classmethod-first-arg=mcs 423 | 424 | 425 | [EXCEPTIONS] 426 | 427 | # Exceptions that will emit a warning when being caught. Defaults to 428 | # "Exception" 429 | overgeneral-exceptions=builtins.StandardError, 430 | builtins.Exception, 431 | builtins.BaseException 432 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling"] 3 | build-backend = "hatchling.build" 4 | 5 | [project] 6 | name = "auto_gpt_plugin_template" 7 | version = "0.0.2" 8 | authors = [ 9 | { name="Torantulino", email="34168009+BillSchumacher@users.noreply.github.com" }, 10 | ] 11 | description = "The template plugin for Auto-GPT." 12 | readme = "README.md" 13 | requires-python = ">=3.8" 14 | classifiers = [ 15 | "Programming Language :: Python :: 3", 16 | "License :: OSI Approved :: MIT License", 17 | "Operating System :: OS Independent", 18 | ] 19 | dependencies = ["abstract-singleton"] 20 | 21 | [project.urls] 22 | "Homepage" = "https://github.com/Torantulino/Auto-GPT" 23 | "Bug Tracker" = "https://github.com/Torantulino/Auto-GPT" 24 | 25 | [tool.black] 26 | line-length = 88 27 | target-version = ['py38'] 28 | include = '\.pyi?$' 29 | extend-exclude = "" 30 | 31 | [tool.isort] 32 | profile = "black" 33 | 34 | [tool.pylint.messages_control] 35 | disable = "C0330, C0326" 36 | 37 | [tool.pylint.format] 38 | max-line-length = "88" -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | black 2 | isort 3 | flake8 4 | pylint 5 | abstract-singleton 6 | wheel 7 | setuptools 8 | build 9 | twine 10 | requests -------------------------------------------------------------------------------- /run_pylint.py: -------------------------------------------------------------------------------- 1 | """ 2 | https://stackoverflow.com/questions/49100806/ 3 | pylint-and-subprocess-run-returning-exit-status-28 4 | """ 5 | import subprocess 6 | 7 | cmd = " pylint src\\**\\*" 8 | try: 9 | subprocComplete = subprocess.run( 10 | cmd, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE 11 | ) 12 | print(subprocComplete.stdout.decode("utf-8")) 13 | except subprocess.CalledProcessError as err: 14 | print(err.output.decode("utf-8")) 15 | -------------------------------------------------------------------------------- /src/AutoGPT_IFTTT/__init__.py: -------------------------------------------------------------------------------- 1 | """This is a plugin to IFTTT Webhooks for Auto-GPT""" 2 | import abc 3 | import os 4 | from pathlib import Path 5 | from typing import Any, Dict, List, Optional, Tuple, TypedDict, TypeVar 6 | 7 | from auto_gpt_plugin_template import AutoGPTPluginTemplate 8 | from dotenv import load_dotenv 9 | from .ifttt import call_webhook 10 | 11 | PromptGenerator = TypeVar("PromptGenerator") 12 | 13 | 14 | class Message(TypedDict): 15 | role: str 16 | content: str 17 | 18 | 19 | class AutoGPT_IFTTT(AutoGPTPluginTemplate): 20 | """ 21 | This is a plugin to IFTTT Webhooks for Auto-GPT 22 | """ 23 | 24 | def __init__(self): 25 | super().__init__() 26 | 27 | self._name = "AutoGPT-IFTTT" 28 | self._version = "0.1.0" 29 | self._description = "AutoGPT IFTTT Webhooks integration." 30 | 31 | with open(str(Path(os.getcwd()) / ".env"), "r", encoding="utf=8") as fp: 32 | load_dotenv(stream=fp) 33 | 34 | self.ifttt_trigger = os.getenv("IFTTT_WEBHOOK_TRIGGER_NAME") 35 | self.ifttt_key = os.getenv("IFTTT_KEY") 36 | 37 | 38 | def can_handle_post_prompt(self) -> bool: 39 | """This method is called to check that the plugin can 40 | handle the post_prompt method. 41 | 42 | Returns: 43 | bool: True if the plugin can handle the post_prompt method.""" 44 | return True 45 | 46 | 47 | def post_prompt(self, prompt: PromptGenerator) -> PromptGenerator: 48 | """This method is called just after the generate_prompt is called, 49 | but actually before the prompt is generated. 50 | 51 | Args: 52 | prompt (PromptGenerator): The prompt generator. 53 | 54 | Returns: 55 | PromptGenerator: The prompt generator. 56 | """ 57 | prompt.add_command( 58 | "ifttt_webhook", 59 | "Create a new webhook call", 60 | { 61 | "title": "", 62 | "summary": "<summary>", 63 | "content": "<content>", 64 | }, 65 | call_webhook, 66 | ) 67 | 68 | return prompt 69 | 70 | def can_handle_on_response(self) -> bool: 71 | """This method is called to check that the plugin can 72 | handle the on_response method. 73 | 74 | Returns: 75 | bool: True if the plugin can handle the on_response method.""" 76 | return False 77 | 78 | 79 | def on_response(self, response: str, *args, **kwargs) -> str: 80 | """This method is called when a response is received from the model.""" 81 | pass 82 | 83 | 84 | def can_handle_on_planning(self) -> bool: 85 | """This method is called to check that the plugin can 86 | handle the on_planning method. 87 | 88 | Returns: 89 | bool: True if the plugin can handle the on_planning method.""" 90 | return False 91 | 92 | 93 | def on_planning( 94 | self, prompt: PromptGenerator, messages: List[Message] 95 | ) -> Optional[str]: 96 | """This method is called before the planning chat completion is done. 97 | 98 | Args: 99 | prompt (PromptGenerator): The prompt generator. 100 | messages (List[str]): The list of messages. 101 | """ 102 | pass 103 | 104 | 105 | def can_handle_post_planning(self) -> bool: 106 | """This method is called to check that the plugin can 107 | handle the post_planning method. 108 | 109 | Returns: 110 | bool: True if the plugin can handle the post_planning method.""" 111 | return False 112 | 113 | 114 | def post_planning(self, response: str) -> str: 115 | """This method is called after the planning chat completion is done. 116 | 117 | Args: 118 | response (str): The response. 119 | 120 | Returns: 121 | str: The resulting response. 122 | """ 123 | pass 124 | 125 | 126 | def can_handle_pre_instruction(self) -> bool: 127 | """This method is called to check that the plugin can 128 | handle the pre_instruction method. 129 | 130 | Returns: 131 | bool: True if the plugin can handle the pre_instruction method.""" 132 | return False 133 | 134 | 135 | def pre_instruction(self, messages: List[Message]) -> List[Message]: 136 | """This method is called before the instruction chat is done. 137 | 138 | Args: 139 | messages (List[Message]): The list of context messages. 140 | 141 | Returns: 142 | List[Message]: The resulting list of messages. 143 | """ 144 | pass 145 | 146 | 147 | def can_handle_on_instruction(self) -> bool: 148 | """This method is called to check that the plugin can 149 | handle the on_instruction method. 150 | 151 | Returns: 152 | bool: True if the plugin can handle the on_instruction method.""" 153 | return False 154 | 155 | 156 | def on_instruction(self, messages: List[Message]) -> Optional[str]: 157 | """This method is called when the instruction chat is done. 158 | 159 | Args: 160 | messages (List[Message]): The list of context messages. 161 | 162 | Returns: 163 | Optional[str]: The resulting message. 164 | """ 165 | pass 166 | 167 | 168 | def can_handle_post_instruction(self) -> bool: 169 | """This method is called to check that the plugin can 170 | handle the post_instruction method. 171 | 172 | Returns: 173 | bool: True if the plugin can handle the post_instruction method.""" 174 | return False 175 | 176 | 177 | def post_instruction(self, response: str) -> str: 178 | """This method is called after the instruction chat is done. 179 | 180 | Args: 181 | response (str): The response. 182 | 183 | Returns: 184 | str: The resulting response. 185 | """ 186 | pass 187 | 188 | 189 | def can_handle_pre_command(self) -> bool: 190 | """This method is called to check that the plugin can 191 | handle the pre_command method. 192 | 193 | Returns: 194 | bool: True if the plugin can handle the pre_command method.""" 195 | return False 196 | 197 | 198 | def pre_command( 199 | self, command_name: str, arguments: Dict[str, Any] 200 | ) -> Tuple[str, Dict[str, Any]]: 201 | """This method is called before the command is executed. 202 | 203 | Args: 204 | command_name (str): The command name. 205 | arguments (Dict[str, Any]): The arguments. 206 | 207 | Returns: 208 | Tuple[str, Dict[str, Any]]: The command name and the arguments. 209 | """ 210 | pass 211 | 212 | 213 | def can_handle_post_command(self) -> bool: 214 | """This method is called to check that the plugin can 215 | handle the post_command method. 216 | 217 | Returns: 218 | bool: True if the plugin can handle the post_command method.""" 219 | return False 220 | 221 | 222 | def post_command(self, command_name: str, response: str) -> str: 223 | """This method is called after the command is executed. 224 | 225 | Args: 226 | command_name (str): The command name. 227 | response (str): The response. 228 | 229 | Returns: 230 | str: The resulting response. 231 | """ 232 | pass 233 | 234 | 235 | def can_handle_chat_completion( 236 | self, messages: Dict[Any, Any], model: str, temperature: float, max_tokens: int 237 | ) -> bool: 238 | """This method is called to check that the plugin can 239 | handle the chat_completion method. 240 | 241 | Args: 242 | messages (List[Message]): The messages. 243 | model (str): The model name. 244 | temperature (float): The temperature. 245 | max_tokens (int): The max tokens. 246 | 247 | Returns: 248 | bool: True if the plugin can handle the chat_completion method.""" 249 | return False 250 | 251 | 252 | def handle_chat_completion( 253 | self, messages: List[Message], model: str, temperature: float, max_tokens: int 254 | ) -> str: 255 | """This method is called when the chat completion is done. 256 | 257 | Args: 258 | messages (List[Message]): The messages. 259 | model (str): The model name. 260 | temperature (float): The temperature. 261 | max_tokens (int): The max tokens. 262 | 263 | Returns: 264 | str: The resulting response. 265 | """ 266 | pass 267 | 268 | 269 | def can_handle_text_embedding(self, text: str) -> bool: 270 | """This method is called to check that the plugin can 271 | handle the text_embedding method. 272 | Args: 273 | text (str): The text to be convert to embedding. 274 | Returns: 275 | bool: True if the plugin can handle the text_embedding method.""" 276 | return False 277 | 278 | 279 | def handle_text_embedding(self, text: str) -> list: 280 | """This method is called when the chat completion is done. 281 | Args: 282 | text (str): The text to be convert to embedding. 283 | Returns: 284 | list: The text embedding. 285 | """ 286 | pass 287 | 288 | 289 | def can_handle_user_input(self, user_input: str) -> bool: 290 | """This method is called to check that the plugin can 291 | handle the user_input method. 292 | 293 | Args: 294 | user_input (str): The user input. 295 | 296 | Returns: 297 | bool: True if the plugin can handle the user_input method.""" 298 | return False 299 | 300 | 301 | def user_input(self, user_input: str) -> str: 302 | """This method is called to request user input to the user. 303 | 304 | Args: 305 | user_input (str): The question or prompt to ask the user. 306 | 307 | Returns: 308 | str: The user input. 309 | """ 310 | 311 | pass 312 | 313 | 314 | def can_handle_report(self) -> bool: 315 | """This method is called to check that the plugin can 316 | handle the report method. 317 | 318 | Returns: 319 | bool: True if the plugin can handle the report method.""" 320 | return False 321 | 322 | 323 | def report(self, message: str) -> None: 324 | """This method is called to report a message to the user. 325 | 326 | Args: 327 | message (str): The message to report. 328 | """ 329 | pass 330 | -------------------------------------------------------------------------------- /src/AutoGPT_IFTTT/ifttt.py: -------------------------------------------------------------------------------- 1 | """This is a plugin to IFTTT Webhooks for Auto-GPT""" 2 | from pprint import pprint 3 | import requests 4 | import os 5 | 6 | 7 | """ 8 | Creates a new Webhook call to IFTTT 9 | 10 | Parameters: 11 | - title: The title of the page. 12 | - summary: A brief summary of the page. 13 | - content: The content of the page. 14 | 15 | Returns: 16 | - If the page is created successfully, returns a string indicating the success 17 | and the URL of the newly created page. 18 | - If there is an error during the creation process, returns the error message. 19 | """ 20 | 21 | 22 | def call_webhook(title: str, summary: str , content: str): 23 | triggerName = os.getenv("IFTTT_WEBHOOK_TRIGGER_NAME") 24 | key = os.getenv("IFTTT_KEY") 25 | 26 | url = "https://maker.ifttt.com/trigger/" + triggerName 27 | url += "/json/with/key/" + key 28 | headers = { 29 | "content-type": "application/json", 30 | } 31 | 32 | payload = { 33 | "data": [ 34 | { 35 | "title": title, 36 | "summary": summary, 37 | "content": content, 38 | }, 39 | ] 40 | } 41 | 42 | response = requests.post(url, headers=headers, json=payload, timeout=60) 43 | return response 44 | -------------------------------------------------------------------------------- /src/AutoGPT_IFTTT/ifttt_test.py: -------------------------------------------------------------------------------- 1 | """ 2 | Test class for IFTTT integration 3 | """ 4 | import os 5 | import unittest 6 | 7 | import requests 8 | 9 | from . import AutoGPT_IFTTT 10 | from .ifttt import call_webhook 11 | 12 | 13 | class TestAutoGPT_IFTTT(unittest.TestCase): 14 | """ 15 | This is the plugin test class for IFTTT Webhooks for Auto-GPT 16 | """ 17 | 18 | def setUp(self): 19 | os.environ["IFTTT_WEBHOOK_TRIGGER_NAME"] = "TestAutoGPT" 20 | os.environ["IFTTT_KEY"] = "TESTKEY" 21 | self.title = "title" 22 | self.content = "this is content" 23 | self.summary= "user testing summary" 24 | 25 | def tearDown(self): 26 | os.environ.pop("IFTTT_WEBHOOK_TRIGGER_NAME", None) 27 | os.environ.pop("IFTTT_KEY", None) 28 | 29 | def test_call_webhook(self): 30 | try: 31 | output = call_webhook( 32 | title=self.title, 33 | summary=self.summary, 34 | content=self.content, 35 | ) 36 | self.assertEqual(output.status_code, 200) 37 | except requests.exceptions.HTTPError as e: 38 | self.assertEqual(e.response.status_code, 401) 39 | 40 | 41 | if __name__ == "__main__": 42 | unittest.main() 43 | --------------------------------------------------------------------------------