Output Adapters

Output format adapter

chatterbot.output.OutputAdapter(**kwargs)[source]

A generic class that can be overridden by a subclass to provide extended functionality, such as delivering a response to an API endpoint.

The output adapter allows the chat bot to return a response in as a Statement object.

chatbot = ChatBot(
    "My ChatterBot",
    output_adapter="chatterbot.output.OutputAdapter",
    output_format="text"
)

Terminal output adapter

chatterbot.output.TerminalAdapter(**kwargs)[source]

A simple adapter that allows ChatterBot to communicate through the terminal.

The output terminal adapter allows a user to type into their terminal to communicate with the chat bot.

chatbot = ChatBot(
    "My ChatterBot",
    output_adapter="chatterbot.output.TerminalAdapter"
)

Gitter output adapter

chatterbot.output.Gitter(**kwargs)[source]

An output adapter that allows a ChatterBot instance to send responses to a Gitter room.

chatbot = ChatBot(
    "My ChatterBot",
    output_adapter="chatterbot.output.Gitter",
    gitter_api_token="my-gitter-api-token",
    gitter_room="my-room-name",
    gitter_only_respond_to_mentions=True,
)

HipChat output adapter

chatterbot.output.HipChat(**kwargs)[source]

An output adapter that allows a ChatterBot instance to send responses to a HipChat room.

This is an output adapter that allows a ChatterBot instance to send responses to a HipChat room.

Be sure to also see the documentation for the HipChat input adapter.

chatbot = ChatBot(
    "My ChatterBot",
    output_adapter="chatterbot.output.HipChat",
    hipchat_host="https://mydomain.hipchat.com",
    hipchat_room="my-room-name",
    hipchat_access_token="my-hipchat-access-token",
)

Microsoft Bot Framework output adapter

chatterbot.output.Microsoft(**kwargs)[source]

An output adapter that allows a ChatterBot instance to send responses to a Micorsoft bot using Direct Line client protocol.

This is an output adapter that allows a ChatterBot instance to send responses to a Microsoft using Direct Line protocol.

Be sure to also see the documentation for the Microsoft input adapter.

chatbot = ChatBot(
    "My ChatterBot",
    output_adapter="chatterbot.output.Microsoft",
    direct_line_host="https://directline.botframework.com",
    direct_line_conservationId="IEyJvnDULgn",
    direct_line_token_or_secret="RCurR_XV9ZA.cwA.BKA.iaJrC8xpy8qbOF5xnR2vtCX7CZj0LdjAPGfiCpg4Fv0",
)

Mailgun output adapter

chatterbot.output.Mailgun(**kwargs)[source]

The Mailgun adapter allows the chat bot to send emails using the Mailgun API.

# -*- coding: utf-8 -*-
from chatterbot import ChatBot
from settings import MAILGUN

'''
To use this example, create a new file called settings.py.
In settings.py define the following:

MAILGUN = {
    "CONSUMER_KEY": "my-mailgun-api-key",
    "API_ENDPOINT": "https://api.mailgun.net/v3/my-domain.com/messages"
}
'''

# Change these to match your own email configuration
FROM_EMAIL = "mailgun@salvius.org"
RECIPIENTS = ["gunthercx@gmail.com"]

bot = ChatBot(
    "Mailgun Example Bot",
    mailgun_from_address=FROM_EMAIL,
    mailgun_api_key=MAILGUN["CONSUMER_KEY"],
    mailgun_api_endpoint=MAILGUN["API_ENDPOINT"],
    mailgun_recipients=RECIPIENTS,
    input_adapter="chatterbot.input.Mailgun",
    output_adapter="chatterbot.output.Mailgun",
    storage_adapter="chatterbot.storage.JsonFileStorageAdapter",
    database="../database.db"
)

# Send an example email to the address provided
response = bot.get_response("How are you?")
print("Check your inbox at ", RECIPIENTS)