How to use the chatterbot.input.InputAdapter function in ChatterBot

To help you get started, we’ve selected a few ChatterBot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gunthercox / ChatterBot / tests / input / test_input_adapter.py View on Github external
def test_process_invalid_input_type(self):
        data = ['A list', 'of text', 'is an', 'invalid input type.']

        with self.assertRaises(InputAdapter.UnrecognizedInputFormatException):
            self.adapter.process_input(data)
github gunthercox / ChatterBot / tests_django / test_input_adapter_integration.py View on Github external
def test_input_adapter(self):
        adapter = InputAdapter(self.chatbot)

        statement = Statement(text='_')

        result = adapter.process_input(statement)

        self.assertEqual(result.text, '_')
github gunthercox / ChatterBot / chatterbot / input / terminal.py View on Github external
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement


class TerminalAdapter(InputAdapter):
    """
    A simple adapter that allows ChatterBot to
    communicate through the terminal.
    """

    def process_input(self, *args):
        """
        Read the user's input from the terminal.
        """
        user_input = input()
        return Statement(text=user_input)
github gunthercox / ChatterBot / chatterbot / input / mailgun.py View on Github external
import datetime
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement


class Mailgun(InputAdapter):
    """
    Get input from Mailgun.
    """

    def __init__(self, **kwargs):
        super(Mailgun, self).__init__(**kwargs)

        # Use the bot's name for the name of the sender
        self.name = kwargs.get('name')
        self.from_address = kwargs.get('mailgun_from_address')
        self.api_key = kwargs.get('mailgun_api_key')
        self.endpoint = kwargs.get('mailgun_api_endpoint')

    def get_email_stored_events(self):
        import requests
github Surendhar95 / ChatBot / chatbot / chatbot / chatterbot / input / mailgun.py View on Github external
from __future__ import unicode_literals
import datetime
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement


class Mailgun(InputAdapter):
    """
    Get input from Mailgun.
    """

    def __init__(self, **kwargs):
        super(Mailgun, self).__init__(**kwargs)

        # Use the bot's name for the name of the sender
        self.name = kwargs.get('name')
        self.from_address = kwargs.get('mailgun_from_address')
        self.api_key = kwargs.get('mailgun_api_key')
        self.endpoint = kwargs.get('mailgun_api_endpoint')

    def get_email_stored_events(self):
        import requests
github gunthercox / ChatterBot / chatterbot / input / hipchat.py View on Github external
from time import sleep
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement


class HipChat(InputAdapter):
    """
    An input adapter that allows a ChatterBot instance to get
    input statements from a HipChat room.
    """

    def __init__(self, **kwargs):
        super(HipChat, self).__init__(**kwargs)

        self.hipchat_host = kwargs.get('hipchat_host')
        self.hipchat_access_token = kwargs.get('hipchat_access_token')
        self.hipchat_room = kwargs.get('hipchat_room')

        import requests
        self.session = requests.Session()
        self.session.verify = kwargs.get('ssl_verify', True)
github Surendhar95 / ChatBot / chatbot / chatbot / chatterbot / input / gitter.py View on Github external
from __future__ import unicode_literals
from time import sleep
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement


class Gitter(InputAdapter):
    """
    An input adapter that allows a ChatterBot instance to get
    input statements from a Gitter room.
    """

    def __init__(self, **kwargs):
        super(Gitter, self).__init__(**kwargs)

        self.gitter_host = kwargs.get('gitter_host', 'https://api.gitter.im/v1/')
        self.gitter_room = kwargs.get('gitter_room')
        self.gitter_api_token = kwargs.get('gitter_api_token')
        self.only_respond_to_mentions = kwargs.get('gitter_only_respond_to_mentions', True)
        self.sleep_time = kwargs.get('gitter_sleep_time', 4)

        authorization_header = 'Bearer {}'.format(self.gitter_api_token)
github Surendhar95 / ChatBot / chatbot / chatbot / chatterbot / input / terminal.py View on Github external
from __future__ import unicode_literals
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement
from chatterbot.utils import input_function


class TerminalAdapter(InputAdapter):
    """
    A simple adapter that allows ChatterBot to
    communicate through the terminal.
    """

    def process_input(self, *args, **kwargs):
        """
        Read the user's input from the terminal.
        """
        user_input = input_function()
        return Statement(user_input)
github gunthercox / ChatterBot / chatterbot / input / mailgun.py View on Github external
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement
from chatterbot.api import mailgun


class Mailgun(InputAdapter):
    """
    Get input from Mailgun.
    """

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        # Use the bot's name for the name of the sender
        self.name = kwargs.get('name')
        self.from_address = kwargs.get('mailgun_from_address')
        self.api_key = kwargs.get('mailgun_api_key')
        self.endpoint = kwargs.get('mailgun_api_endpoint')

    def process_input(self, statement):
        urls = mailgun.get_stored_email_urls(self.api_key, self.endpoint)
        url = list(urls)[0]
github gunthercox / ChatterBot / chatterbot / input / microsoft.py View on Github external
from time import sleep
from chatterbot.input import InputAdapter
from chatterbot.conversation import Statement
from chatterbot.api import microsoft


class Microsoft(InputAdapter):
    """
    An input adapter that allows a ChatterBot instance to get
    input statements from a Microsoft Bot using *Directline client protocol*.
    https://docs.botframework.com/en-us/restapi/directline/#navtitle
    """

    def __init__(self, chatbot, **kwargs):
        super().__init__(chatbot, **kwargs)
        import requests
        from requests.packages.urllib3.exceptions import InsecureRequestWarning
        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

        # NOTE: Direct Line client credentials are different from your bot's credentials
        self.direct_line_token_or_secret = kwargs.get(
            'direct_line_token_or_secret'
        )