Skip to content
This repository was archived by the owner on Dec 7, 2022. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

11 Commits

.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:

usingChatbase;Chatbase.Clientclient=newChatbase.Client();Chatbase.Messagemsg=newChatbase.Message();msg.api_key="123";// requiredmsg.user_id="xyz";// requiredmsg.intent="test";msg.version="0.1";msg.content="This is a test.";msg.type=Chatbase.Message.UserMessage;// default, requiredmsg.not_handled=false;// defaultmsg.feedback=false;//defaultvarresp=client.Send(msg).Result;// Get the result of the async task// Write the return status-code from the API requestConsole.WriteLine(resp.StatusCode);

Facebook:

usingChatbase;Chatbase.Clientclient=newChatbase.Client();// Agent messagesagnMsg=newChatbase.FBAgentMessage();agnMsg.SetRecipientID("123");agnMsg.SetMessageID("456");agnMsg.SetMessageContent("hey");agnMsg.intent="say-hello";agnMsg.version="0.2";varfirstTask=client.Send(agnMsg);// User messagesusrMsg=newChatbase.FBUserMessage();usrMsg.SetSenderID("abc");usrMsg.SetRecipientID("123");usrMsg.SetMessageID("456");usrMsg.SetMessageContent("hey");usrMsg.intent="say-hello";usrMsg.version="0.2";varsecondTask=client.Send(usrMsg);

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

Generic:

usingChatbase;Chatbase.Clientclient=newChatbase.Client();Chatbase.MessageSetset=newChatbase.MessageSet("api-key");// New messages made from the set will have the api-key already setChatbase.Messagemsg=set.NewMessage();// ... Set fields as one would a regular message like the example aboveset.Add(msg)vartask=Client.Send(set);

Facebook:

usingChatbase;Chatbase.Clientclient=newChatbase.Client();// Agent Message SetChatbase.FBAgentMessageSetagnSet=newChatbase.FBAgentMessageSet("api-key");Chatbase.FBAgentMessageagnMsg=agnSet.NewMessage();// ... Set fields as one would a regular FBAgentMessageagnSet.add(agnMsg)varfirstTask=client.Send(agnSet);// User Message SetChatbase.FBUserMessageSetusrSet=newChatbase.FBUserMessageSet("api-key");Chatbase.FBUserMessageusrMsg=usrSet.NewMessage();// ... Set fields as one would a regular FBUserMessageusrSet.add(usrMsg);varsecondTask=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!

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

22 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages