cleverbot.io
Installation
To install this package, enter the following in your console
go get github.com/CleverbotIO/go-cleverbot.io
Before using this module, please get your API keys at http://cleverbot.io/keys
Usage
To initialize the Cleverbot, create a new instance.
package main
import (
"fmt"
"log"
"github.com/CleverbotIO/go-cleverbot.io"
)
func main() {
// The api key is given to you at https://cleverbot.io/keys.
apiUser := "YOUR_API_USER"
apiKey := "YOUR_API_KEY"
// apiNick is optional.
apiNick := ""
// Initialize Cleverbot
bot, err := cleverbot.New(apiUser, apiKey, apiNick)
if err != nil {
log.Fatal(err)
}
cleverbot.io allows you to save cleverbot sessions to access later. To utilize this feature, you can create a new instance with a third parameter.
// apiNick is optional.
apiNick := "sessionName"
Now querying the cleverbot is simple, you pass the text to the .Ask()
method
// Send Cleverbot a message.
response, err := bot.Ask("hello world")
if err != nil {
log.Fatal(err)
}
// Print the response.
fmt.Println(response)
// "World? Who is world? My name is Timmy."
}
For more examples: https://github.com/CleverbotIO/go-cleverbot.io/tree/master/_examples
Well, that's it for now! Happy hacking!