Chatterbot: Setting up a chatterbot using MongoDB with a user/pass combo

Created on 20 May 2017  路  2Comments  路  Source: gunthercox/ChatterBot

I'm trying to setup a chatterbot with MongoDB, and I'm having issues authenticating with my bot script. Basically, I don't know if the MongoDatabaseAdapter object allows for authentication. Here's my code:

# Create a new ChatBot instance
bot = ChatBot('Terminal',
    storage_adapter='chatterbot.storage.MongoDatabaseAdapter',
    logic_adapters=[
    'chatterbot.logic.BestMatch'
    ],
    filters=[
    'chatterbot.filters.RepetitiveResponseFilter'
    ],
    input_adapter='chatterbot.input.TerminalAdapter',
    output_adapter='chatterbot.output.TerminalAdapter',
    database='ava_database',
    database_uri='127.0.0.1:27017'
)

The code worked when I first installed Mongo DB, but I wanted to protect the database a bit, so I created a user/pass combo to use with the project. Unfortunately, I don't know how to create a chatbot instance using my user/pass combo.

Has anyone ran into this issue using MongoDB? Did you create your own object, or is there a parameter that I'm missing somewhere.

Most helpful comment

Try like this

# Create a new ChatBot instance
bot = ChatBot('Terminal',
    storage_adapter='chatterbot.storage.MongoDatabaseAdapter',
    logic_adapters=[
    'chatterbot.logic.BestMatch'
    ],
    filters=[
    'chatterbot.filters.RepetitiveResponseFilter'
    ],
    input_adapter='chatterbot.input.TerminalAdapter',
    output_adapter='chatterbot.output.TerminalAdapter',
    database='ava_database',
    database_uri='mongodb://user:password@server:port/''
)

More information available here https://docs.mongodb.com/manual/reference/connection-string/

All 2 comments

Try like this

# Create a new ChatBot instance
bot = ChatBot('Terminal',
    storage_adapter='chatterbot.storage.MongoDatabaseAdapter',
    logic_adapters=[
    'chatterbot.logic.BestMatch'
    ],
    filters=[
    'chatterbot.filters.RepetitiveResponseFilter'
    ],
    input_adapter='chatterbot.input.TerminalAdapter',
    output_adapter='chatterbot.output.TerminalAdapter',
    database='ava_database',
    database_uri='mongodb://user:password@server:port/''
)

More information available here https://docs.mongodb.com/manual/reference/connection-string/

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AfrahAsif picture AfrahAsif  路  3Comments

gunthercox picture gunthercox  路  3Comments

gunthercox picture gunthercox  路  3Comments

coolrb picture coolrb  路  3Comments

AmusingThrone picture AmusingThrone  路  3Comments