Skip to content

pierredavidbelanger/chatter-bot-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chatter Bot API

A Mono/.NET, JAVA, Python and PHP chatter bot API that supports Cleverbot, JabberWacky and Pandorabots.

For a Ruby version, have a look at Gabriele Cirulli cleverbot-api implementation.

If you are planing using the .NET version, maybe this fork by Schumix is worth looking at.

News

2017-02-13: This project's v2 branch is an in progress refactor/cleanup effort. For now I have a working Java version that uses the new Cleverbot official API. No code breaking changes were required, except that you will now need an API Key when calling factory.create(ChatterBotType.CLEVERBOT, "YOURAPIKEY").

2017-01-04: Folks at Existor (the company behind Cleverbot) have concerns because this project goes against their terms of usage. Indeed, their service costs money (to host their huge servers for example) and this project allows users to bypass their ads. I acknowledged that this project does not makes a fair use of their service. I would be the first to be mad if someone would make an unfair use of one of my project, so I understand their positions. We agreed on this: this project will send a parameter on each request that will uniquely identify the project itself. They will collect metrics, and let the project alone if they found that the project usage does not make a big difference for them.

2015-09-21: Thanks to S.R, the python version is now also compatible with python 3.

2014-10-17: Merged a bunch of nicely arranged pull requests sent by Csaba Jakosa. Those include works done by Christian Gärtner (for the PHP version), and Arnaud Aliès (for the Python version).

2014-10-11: Moved to GitHub!

2014-08-04: The Java version is now on The Maven Central Repository. This is a request I get from time to time. I was too lazy to do it until now. But this time a user was kind enough, so I kick myself and did it (thanks Hardik!). Just add this dependency to your pom file.

2014-03-31: Cleverbot seems to stops working from time to time. You should expect it to be really unstable until I find a fix.

2014-02-02: Cleverbot stops working. Thanks to Matthew to let me know.

2013-11-15: Cleverbot stops working, they changed their API again. I am working on this.

2013-08-29: There is a bug with Cleverbot in any language right now. I will fix it as soon as possible. A bug with Cleverbot is now fixed in the new 1.3 revision release. Enjoy! (Kevin, Alienmario, Rai: Thanks to you guys for letting me know)

Download

I encourage you to download a compiled version of the library (TBA), and try the example below in this page. I tried to keep all the libraries free from dependencies, so you do not need to download anything else.

Be sure to always use the latest version of the library, as the Cleverbot/JabberWacky Web Service is changing over time. I suppose it is not meant to be public.

Maven

Just add this dependency to your pom file:

<dependency>
    <groupId>ca.pjer</groupId>
    <artifactId>chatter-bot-api</artifactId>
    <version>1.4.7</version>
</dependency>

Going further

If you like what you see, browse and comment the source code. If you found a bug or something missing, consult the Issues section before posting a new defect or a new enhancement. Also I will gladly accept Pull Requests

Disclaimer

I am not the owner of Cleverbot/JabberWacky nor Pandorabots.

My work (the Cleverbot/JabberWacky part) is based on pycleverbot, a Python bindings for the Cleverbot.

Contact

You can also let me know what you think.

Examples

Mono/.NET C#

using System;

using ChatterBotAPI;

namespace ChatterBotAPITest {
        
        class MainClass {
                
                public static void Main(string[] args) {
                        ChatterBotFactory factory = new ChatterBotFactory();
                        
                        ChatterBot bot1 = factory.Create(ChatterBotType.CLEVERBOT);
                        ChatterBotSession bot1session = bot1.CreateSession();
                        
                        ChatterBot bot2 = factory.Create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
                        ChatterBotSession bot2session = bot2.CreateSession();
                        
                        string s = "Hi";
                        while (true) {
                                
                                Console.WriteLine("bot1> " + s);
                                
                                s = bot2session.Think(s);
                                Console.WriteLine("bot2> " + s);
                                
                                s = bot1session.Think(s);
                        }
                }
        }
}

Mono/.NET VB

Imports ChatterBotAPI

Public Class Application

        Public Shared Sub Main()
                Dim factory As ChatterBotFactory = new ChatterBotFactory()
                
                Dim bot1 As ChatterBot = factory.Create(ChatterBotType.CLEVERBOT)
                Dim bot1session As ChatterBotSession = bot1.CreateSession()
                
                Dim bot2 As ChatterBot = factory.Create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477")
                Dim bot2session As ChatterBotSession = bot2.CreateSession()
        
                Dim s As String = "Hi"
                Do While true
                
                        Console.WriteLine("bot1> " + s)
                        
                        s = bot2session.Think(s)
                        Console.WriteLine("bot2> " + s)
                                
                        s = bot1session.Think(s)
                Loop
        End Sub
End Class

JAVA

package com.google.code.chatterbotapi.test;

import com.google.code.chatterbotapi.*;

public class ChatterBotApiTest {
    
    public static void main(String[] args) throws Exception {
        ChatterBotFactory factory = new ChatterBotFactory();

        ChatterBot bot1 = factory.create(ChatterBotType.CLEVERBOT);
        ChatterBotSession bot1session = bot1.createSession();

        ChatterBot bot2 = factory.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
        ChatterBotSession bot2session = bot2.createSession();

        String s = "Hi";
        while (true) {

            System.out.println("bot1> " + s);

            s = bot2session.think(s);
            System.out.println("bot2> " + s);

            s = bot1session.think(s);
        }
    }
}

Python

from chatterbotapi import ChatterBotFactory, ChatterBotType

factory = ChatterBotFactory()

bot1 = factory.create(ChatterBotType.CLEVERBOT)
bot1session = bot1.create_session()

bot2 = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
bot2session = bot2.create_session()

s = 'Hi'
while (1):
    
    print 'bot1> ' + s
    
    s = bot2session.think(s);
    print 'bot2> ' + s
    
    s = bot1session.think(s);

PHP

<?php
    require 'chatterbotapi.php';
    
    $factory = new ChatterBotFactory();
    
    $bot1 = $factory->create(ChatterBotType::CLEVERBOT);
    $bot1session = $bot1->createSession();
    
    $bot2 = $factory->create(ChatterBotType::PANDORABOTS, 'b0dafd24ee35a477');
    $bot2session = $bot2->createSession();
    
    $s = 'Hi';
    while (1) 
    {
        echo "bot1> $s\n";
        
        $s = $bot2session->think($s);
        echo "bot2> $s\n";
        
        $s = $bot1session->think($s);
    }
?>

About

A Mono/.NET, JAVA, Python and PHP chatter bot API that supports Cleverbot, JabberWacky and Pandorabots.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published