Skip to main content

instachatbot

PyPI version

Simple framework for building Instagram chat bots with menu driven interface

Installation

pip3 install instachatbot

To install development version:

pip3 install git+https://github.com/art-vasilyev/instachatbot.git

How to use

Create sample script main.py:

from instachatbot.bot import InstagramChatBot
from instachatbot.nodes import (
    MenuNode, MenuItem, MessageNode, QuestionnaireNode, NotifyAdminNode)

menu = MenuNode(
    '💡Choose menu:\n',
    [
        MenuItem(
            'text message',
            MessageNode('This is a message😀')),
        MenuItem(
            'questionnaire',
            QuestionnaireNode(
                [
                    'What is your favourite book? 📚',
                    'What is your favourite fruit? 🍐 🍊 🍋'
                ],
                header='Please answer the following questions',
                admin_username='<user to send results to>',
                response='Thank your for your answers')),
        MenuItem(
            'send notification to admin',
            NotifyAdminNode(
                'Thank you',
                notification='Sample notification from bot user',
                admin_username='<username to send notification to>'
            )
        ),
    ],
    error_message='Failed to select menu.'
)

chatbot = InstagramChatBot(menu=menu)
chatbot.login(
    username='<instagram-username>',
    password='<instagram-password>')
chatbot.start()

Run the script:

python3 main.py

Persistent conversation state

By default conversation state is discarded on bot restart, to make it persistent you should provide persistent storage on bot initialization:

chatbot = InstagramChatBot(menu=menu, storage=FileStorage())

Menu triggers

By default a bot sends the menu on any message it receives. If you want menu to appear only if bot receives special message, set trigger argument on bot initialization:

chatbot = InstagramChatBot(menu=menu, trigger='/menu')

Metadata

Release files for instachatbot 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for instachatbot 0.4
File Size Uploaded Provenance Actions
instachatbot-0.4.tar.gz 6.0 kB Without provenance Details for instachatbot-0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for instachatbot 0.4
File Interpreter ABI Platform Actions
instachatbot-0.4-py3-none-any.whl Python 3 none any Details for instachatbot-0.4-py3-none-any.whl

Total release size: 13.0 kB

Release files / instachatbot-0.4.tar.gz

Download URL instachatbot-0.4.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2b78f750f5a4f0da8df82d49385e570f85f1ab6e69802c52d8fef59ede9e8444
BLAKE2b-256 checksum
How to use checksums
82626a7a61d1c42f9467158a0da8e8b30650dacaa045a776d43f5a26c8fdaee5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Release files / instachatbot-0.4-py3-none-any.whl

Download URL instachatbot-0.4-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9bfc6ca6eeaf75f24e00156792a04d55c39a472accbd36f6c6efc89880ea3b50
BLAKE2b-256 checksum
How to use checksums
0dae95e1c53387df77058796699a671ea5b204d7d52ef32d5d07f78e77a91557
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Security for instachatbot 0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page