Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

ssb-bot πŸ’» πŸ’¬

npm install --save ssb-bot


original post: %2JaltAdhcWnJwOXJPbHvGE9+SlVrR7Vfq+RhJbMhVUM=.sha256

ssb-bot is scuttlebot plugin to help make it easy to develop conversational user interfaces, similar to a Slack bot or a Facebook Messenger bot.


var bot = Bot({
  name: 'greeter',
  version: '0.0.0',
  initBot: (sbot) => {
    var { id } = sbot.whoami()
    var hasMentionForBot = hasMentionFor(id)

    return {

    function handleMessage (state, message) {
      if (hasMentionForBot(message)) {
        return {
          action: {
            type: 'hello',

      return { state }

    function handleAction (action, sbot, cb) {
      var { type } = action
      if (type === 'hello') {
        var { id } = action
        sbot.about.get((err, abouts) => {
          if (err) return cb(err)
          var name = abouts[id].name[id][0]
          cb(null, {
            type: 'post',
            text: `hello [@${name}](${id})!`,
            mentions: [
                link: id
      else cb()

see example.js and examples/hello.js for the full example source.

with your main Scuttlebutt client (such as Patchwork) running, run node example hello, which should create a new bot who will request to replicate with your current feed.

if you @mention this new bot, it should respond with hello ${name}!

(you may need to restart the bot once or twice after sending a message)


@mix brought up the idea of developing systems butt-first: %3MS64b+lB4Dk5gag8tJKnA+zy8BEQ2cLmyxF06sBKyM=.sha256. with this approach, we use ssb as a database, where a "api call" is publishing a message to your feed and a "database transaction" is the bot publishing a message to their feed.

i want to make it easier for people to create pub invites, as currently the only way is for a pub owner to ssh into their server and run sbot invite.create 1. (easy-ssb-pub gets around this by allowing anyone to create an invite from a public webpage, but i want something to help the network grow with personal invites.)

so i'm interested in a conversational approach to creating invites. i want to be able to private message a pub and say "hey can i have an invite?" and the pub responds with "sure, here you go: .... !"


inspired by Elm or inu:

a bot is two functions:

handleMessage receives the current state and the next message, returns the next state and any new actions.

var handleMessage = (state, message) => {
  return {
    state: nextState,

handleAction receives the new action and asyncronously returns (via the callback) a new message to publish.

var handleAction = (action, sbot, callback) => {
  var newMessageContent = {
    type: 'post',
    text: 'did i hear something?'
  callback(null, newMessageContent) // this publishes the new message content


The Apache License

Copyright Β© 2017 Michael Williams

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


conversational user interfaces for Scuttlebutt πŸ€–






No packages published