Git Product home page Git Product logo

hopr-chatbot's Introduction

HOPR Logo

HOPR Chatbot

HOPR is a privacy-preserving messaging protocol which enables the creation of a secure communication network via relay nodes powered by economic incentives using digital tokens. HOPR Chatbot is a proof-of-concept aimed to showcase the capabilities of a HOPR Node by using our gRPC-enabled HOPR Server, which listens to messages and replies to the recipients of them, whenever their address is included in the original message.

Overview

HOPR Chatbot is a node.js application that connects to an instance of a HOPR Server, and listens to any calls done against such server. Upon receiving a message with a valid recipient, it provides an answer given the bot that is currently loaded. At the time of writing, HOPR Chatbot dynamically loads bots based in the ENV given, and each bot has different capabilities.

Existing Bots

  • 🃏 Randobot: Generates random words when messaged.
  • 🐦 Tweetbot: Asks for a tweet including your address, #HOPRGames and @hoprnet in it.

Bots in Progress

  • 🥊 Bouncerbot: Blocks you from entering a “party”, but will give you some hints to enter afterwards. See issue.

Requirements

  • Docker
  • Node.js >=v12

Setup

HOPR Server

We have bundled a working version of HOPR Server in this repository as a docker-compose.yml. Just run docker-compose up server to get an instance running locally at 127.0.0.1:50051.

Chatbot

  1. Install dependancies: yarn
  2. Start bot: API_URL=127.0.0.1:50051 yarn start

Deployment

Right now, we have a Dockerfile that bundles bot a hopr-server and a hopr-chatbot instance by relying on pm2 to manage both process. This practice is frown upon in the Docker ecosystem, but simplifies our deployment process. To build such image, you can simply do docker build -f chatbot.Dockerfile . -t hoprnet/chatbot:latest.

Additional information

Payload format

In order for the bot to know to which address it should send a reply back to, we need to include the sender's address in the payload. The bot expects that the first 53 bytes of the payload will be the sender's address in a base58 format, for example 16Uiu2HAkwsN4GVHQr1szVurz6u4V6uB9ZJacey471Pg2nTxHvP47, everything after that is the actual message. This is implemented in message.ts.

As of version 1.3.0 of HOPR Chat, the command includeRecipient will effectively add the recipient address into every message.

Example (using hopr-chat)

<1.3.0

# find out your address
> myAddress
ethereum:  0xa51e98e0d9b6c387139e5ce06c2580e922d1a46b
HOPR:      16Uiu2HAkwsN4GVHQr1szVurz6u4V6uB9ZJacey471Pg2nTxHvP47

> send 16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj

# include your address in the message
> 16Uiu2HAkwsN4GVHQr1szVurz6u4V6uB9ZJacey471Pg2nTxHvP47hello world

>=1.3.0

# call includeRecipient
> includeRecipient
Are you sure you want to include your address in your messages? (y, N):
You have set your “includeRecipient” settings to yes

> send 16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj

# send message as normal
> hello world

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.