GithubHelp home page GithubHelp logo

krismuniz / botkit-sms Goto Github PK

View Code? Open in Web Editor NEW
19.0 3.0 10.0 17 KB

Twilio Programmable SMS implementation for Botkit.

Home Page: https://www.npmjs.com/package/botkit-sms

License: Other

JavaScript 100.00%
botkit twilio botkit-sms sms phone-number

botkit-sms's Introduction

🚨Deprecated in favor of botkit!

The official Botkit project now supports Twilio SMS! Install botkit instead. If you already use botkit-sms please consider switching as this project is no longer maintained.

botkit-sms

npm Dependency Status Code-Style:Standard License:MIT

botkit-sms allows you to create conversational SMS apps ("bots") via Twilio's Programmable SMS API using Botkit's familiar interface.

It takes advantage of Botkit's core functionality thus allowing you to create complex conversational flows via a simple interface. It also allows you to use custom storage methods/systems to enable data persistence across sessions.

What is Botkit?

Here's an excerpt of Botkit's readme.md file:

[Botkit] provides a semantic interface to sending and receiving messages so that developers can focus on creating novel applications and experiences instead of dealing with API endpoints.

Use Case

You can use botkit-sms to build SMS bots with moderately-complex conversational flows.

Installation

$ npm install --save botkit-sms

Usage

Note: This document assumes that you are familiarized with Botkit and Twilio's Programmable SMS API

To connect your bot to Twilio you must point a Messaging webhook to http://your_host/sms/receive, after doing so, every Twilio message will be sent to that address.

Then you need to write your bot. First, create a TwilioSMSBot instance and pass an object with your configuration properties:

const TwilioSMSBot = require('botkit-sms')
const controller = TwilioSMSBot({
  account_sid: process.env.TWILIO_ACCOUNT_SID,
  auth_token: process.env.TWILIO_AUTH_TOKEN,
  twilio_number: process.env.TWILIO_NUMBER
})

spawn() your bot instance:

let bot = controller.spawn({})

Then you need to set up your Web server and create the webhook endpoints so your app can receive Twilio's messages:

controller.setupWebserver(process.env.PORT, function (err, webserver) {
  controller.createWebhookEndpoints(controller.webserver, bot, function () {
    console.log('TwilioSMSBot is online!')
  })
})

And finally, you can setup listeners for specific messages, like you would in any other botkit bot:

controller.hears(['hi', 'hello'], 'message_received', (bot, message) => {
  bot.startConversation(message, (err, convo) => {
    convo.say('Hi, I am Oliver, an SMS bot! :D')
    convo.ask('What is your name?', (res, convo) => {
      convo.say(`Nice to meet you, ${res.text}!`)
      convo.next()
    })
  })
})

controller.hears('.*', 'message_received', (bot, message) => {
  bot.reply(message, 'huh?')

  // send an image
  bot.reply(message, {
    body: 'Optional body to go with text',
    mediaUrl: 'https://i.imgur.com/9n3qoKx.png'
  })
})

See full example in the examples directory of this repo.

Reference

Please see botkit's guide and reference document here.

Contributing

This project is no longer maintained. Consider forking or –better yet– contributing to the official Botkit instead.

License

The MIT License (MIT)

Copyright (c) 2016 Kristian Muñiz

botkit-sms's People

Contributors

krismuniz avatar matthewrossanderson avatar prichey avatar shanepelletier avatar twelvearrays avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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