GithubHelp home page GithubHelp logo

isabella232 / chatbase-dotnet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from google/chatbase-dotnet

0.0 0.0 0.0 19 KB

Integrate your DotNet application with Chatbase!

Home Page: https://chatbase.com/

License: Apache License 2.0

C# 100.00%

chatbase-dotnet's Introduction

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

chatbase-dotnet's People

Contributors

cristiancavalli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.