Giter Club home page Giter Club logo

make-rails's Introduction

Root Insurance Bots

This is a Rails app that allows a user to engage with the Root Insurance API via either a Slack bot or an Alexa skill.

Bots

  1. Slack Bot
  2. Alexa Bot (Alexa skill)

Slack Bot

This is a basic slack bot with three commands:

  1. Get a list of all phone brands
  2. Get a list of all phones made by brand
  3. Get the value of a specific phone

Settings up the Slack bot

The first thing you have to do is to register a Slack bot and obtain the SLACK_API_TOKEN. You can create a new Bot Integration here services/new/bot.

Implementation

The bot lives in lib/slack-insure-bot.

The part to pay attention to is how you structure the commands. For example creating a command to list all phone brands will be structure like this:

module SlackInsureBot
  module Commands
    class Default < SlackRubyBot::Commands::Base
      command 'list all phone brands' do |client, data, _match|
        brands = ["Samsung", "Apple", "Nokia"]

        client.say(channel: data.channel, text: brands.join("\n"))
      end
    end
  end
end

Additional information and Examples

Check out slack-ruby-bot. This is the main lib where everything is copied from ;)

Alexa Bot (Alexa Skill)

An Alexa Skill is essentially an app that runs on an Amazon Echo.

You can ask Alexa to:

  1. Get a list of all phone brands
  2. Get a list of all phones made by brand

Setting up the Alexa Skill

  • Setup an Amazon Echo and register it using your personal Amazon account.
  • Register for an Amazon developer account and setup the Alexa skill here.
Skill Information

Add "Insurance Helper" as both the Name and the Invocation Name.

Interaction Model

The interaction model is by far the hardest part of creating an Alexa skill. I suggest reading this and watching this video in order to get a basic understanding of what is required to create an interaction model.

  1. Add the JSON blob found in interaction_model/intent_schema.json in the Intent Schema field.
  2. Create a new Custom Slot Type and the values found in interaction_model/custom_slots/LIST_OF_BRANDS.
  3. Add the Sample Utterances found in interaction_model/sample_utterances.txt in the Sample Utterances field.
Configuration
  1. Select HTTPS as the Service Endpoint Type.
  2. Once you've started the app, you need to use ngrok to expose your local server to the internet. Once your app is running, you need to run ngrok http 3000 to do this. You'll then get an url which you can add in the Default field. It will looks something like this https://056d1d30.ngrok.io/alexa.
SSL Configuration

Select the option My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority.

Implementation

The Alexa skill posts data to the WebhooksController. Here we then call the AlexaService which figures out the intent of the request and generates a response. This gets send back to the Alexa Skill and is verbalized by the Echo.

Additional information

Running the app

The first step is to add the necessary secrets in config/settings.yml.

Install the gems

bundle install

Run migrations

rails db:migrate

Start the server

rails s

Setup ngrok to expose the endpoint

ngrok http 3000

make-rails's People

Contributors

gysmuller avatar glasnoster avatar

Watchers

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