Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.
/ hopr-chatbot Public archive

Simple bot on top of a HOPR node able to listen and reply to messages using a gRPC server.

Notifications You must be signed in to change notification settings

hoprnet/hopr-chatbot

Repository files navigation

This repository is no longer maintained.

Please go to https://github.com/hoprnet/hoprnet and https://github.com/hoprnet/hopr-devrel for latest developments in the HOPR protocol and HOPR apps development.


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

LinkDrop Setup

  • To setup LinkDrop, you have to manually create a campaign at linkdrop. Choose the same account and erc20 token address that you provide in the .env file. Make sure it is a campaign id is 1 to perform one to one transactions multiple times. You can choose any other campaign id but then the payment channel would be generated only for the number of links decided on the time of campaign creation.

  • Copy the .env.example to .env and add the required variables.

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

About

Simple bot on top of a HOPR node able to listen and reply to messages using a gRPC server.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published