Skip to content

isabella232/chatbase-dotnet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.NET Library for Chatbase

A .NET library for the Chatbase API written in C#

This is not an official Google product.

Package Information

Nuget package page

Install

Using the Package Manager Console run the following command:

Install-Package Chatbase

Account Setup

Please see the Getting Started Section for information on configuring one's account and obtaining an API key.

Using the library

One can send individual messages to the Generic and Facebook rest APIs:

Generic:

using Chatbase;

Chatbase.Client client = new Chatbase.Client();

Chatbase.Message msg = new Chatbase.Message();
msg.api_key = "123"; // required
msg.user_id = "xyz"; // required
msg.intent = "test";
msg.version = "0.1";
msg.content = "This is a test.";
msg.type = Chatbase.Message.UserMessage; // default, required
msg.not_handled = false; // default
msg.feedback = false; //default
var resp = client.Send(msg).Result; // Get the result of the async task
// Write the return status-code from the API request
Console.WriteLine(resp.StatusCode);

Facebook:

using Chatbase;

Chatbase.Client client = new Chatbase.Client();

// Agent messages
agnMsg = new Chatbase.FBAgentMessage();
agnMsg.SetRecipientID("123");
agnMsg.SetMessageID("456");
agnMsg.SetMessageContent("hey");
agnMsg.intent = "say-hello";
agnMsg.version = "0.2";
var firstTask = client.Send(agnMsg);

// User messages
usrMsg = new Chatbase.FBUserMessage();
usrMsg.SetSenderID("abc");
usrMsg.SetRecipientID("123");
usrMsg.SetMessageID("456");
usrMsg.SetMessageContent("hey");
usrMsg.intent = "say-hello";
usrMsg.version = "0.2";
var secondTask = client.Send(usrMsg);

One can send sets of messages as well to the Generic and Facebook rest APIs:

Generic:

using Chatbase;

Chatbase.Client client = new Chatbase.Client();

Chatbase.MessageSet set = new Chatbase.MessageSet("api-key");

// New messages made from the set will have the api-key already set
Chatbase.Message msg = set.NewMessage();
// ... Set fields as one would a regular message like the example above
set.Add(msg)
var task = Client.Send(set);

Facebook:

using Chatbase;

Chatbase.Client client = new Chatbase.Client();

// Agent Message Set
Chatbase.FBAgentMessageSet agnSet = new Chatbase.FBAgentMessageSet("api-key");
Chatbase.FBAgentMessage agnMsg = agnSet.NewMessage();
// ... Set fields as one would a regular FBAgentMessage
agnSet.add(agnMsg)
var firstTask = client.Send(agnSet);

// User Message Set
Chatbase.FBUserMessageSet usrSet = new Chatbase.FBUserMessageSet("api-key");
Chatbase.FBUserMessage usrMsg = usrSet.NewMessage();
// ... Set fields as one would a regular FBUserMessage
usrSet.add(usrMsg);
var secondTask = client.Send(usrSet);

Tests

Please place tests in Chatbase.Tests project directory. To run tests, from the Chatbase.Tests project directory enter the following in a command-prompt:

$ dotnet test

This requires the dotnet Core CLI tools to be installed.

About

Integrate your DotNet application with Chatbase!

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%