GithubHelp home page GithubHelp logo

twiliodeved / sdk-starter-ruby Goto Github PK

View Code? Open in Web Editor NEW
17.0 20.0 12.0 77 KB

Demo application showcasing Twilio API usage in Ruby

Home Page: http://www.twilio.com/docs

License: MIT License

Ruby 20.99% JavaScript 39.91% CSS 10.41% HTML 26.94% Shell 1.75%
sdk starter-kit ruby twilio

sdk-starter-ruby's Introduction

Twilio

Twilio SDK Starter Application for Ruby

This sample project demonstrates how to use Twilio APIs in a Ruby web application. Once the app is up and running, check out the home page to see which demos you can run. You'll find examples for Chat, Notify, and Sync.

Let's get started!

Configure the sample application

To run the application, you'll need to gather your Twilio account credentials and configure them in a file named .env. To create this file from an example template, do the following in your Terminal.

cp .env.example .env

Open .env in your favorite text editor and configure the following values.

Configure account information

Every sample in the demo requires some basic credentials from your Twilio account. Configure these first.

Config Value Description
TWILIO_ACCOUNT_SID Your primary Twilio account identifier - find this in the console here.
TWILIO_API_KEY Used to authenticate - generate one here.
TWILIO_API_SECRET Used to authenticate - just like the above, you'll get one here.

A Note on API Keys

When you generate an API key pair at the URLs above, your API Secret will only be shown once - make sure to save this information in a secure location, or possibly your ~/.bash_profile.

Configure Development vs Production Settings

By default, this application will run in production mode - stack traces will not be visible in the web browser. If you would like to run this application in development locally, change the APP_ENV variable in your .env file.

APP_ENV=development

For more about development vs production, visit Sinatra's configuration page.

Configure product-specific settings

Depending on which demos you'd like to run, you may need to configure a few more values in your .env file.

Configuring Twilio Sync

Twilio Sync works out of the box, using default settings per account. Once you have your API keys configured, run the application (see below) and open a browser!

Configuring Twilio Chat

In addition to the above, you'll need to generate a Chat Service in the Twilio Console. Put the result in your .env file.

Config Value Where to get one.
TWILIO_CHAT_SERVICE_SID Generate one in the Twilio Chat console

With this in place, run the application (see below) and open a browser!

Configuring Twilio Notify

You will need to create a Notify Service and add at least one credential on the Mobile Push Credential screen (such as Apple Push Notification Service or Firebase Cloud Messaging for Android) to send notifications using Notify.

Config Value Where to get one.
TWILIO_NOTIFICATION_SERVICE_SID Generate one in the Notify Console and put this in your .env file.
A Push Credential Generate one with Apple or Google and configure it as a Notify credential.

Once you've done that, run the application (see below) and open a browser!

Run the sample application

Now that the application is configured, we need to install our dependencies with Bundler.

bundle install

Now we should be all set! Run the application using the bundle exec command.

bundle exec ruby app.rb

Your application should now be running at http://localhost:4567/.

Home Screen

Check your config values, and follow the links to the demo applications!

Running the SDK Starter Kit with ngrok

If you are going to connect to this SDK Starter Kit with a mobile app (and you should try it out!), your phone won't be able to access localhost directly. You'll need to create a publicly accessible URL using a tool like ngrok to send HTTP/HTTPS traffic to a server running on your localhost. Use HTTPS to make web connections that retrieve a Twilio access token.

ngrok http 4567

License

MIT

sdk-starter-ruby's People

Contributors

atampere avatar hortega avatar jefflinwood avatar juank-pa avatar lgerzz avatar po5i avatar well1791 avatar

Stargazers

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

Watchers

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

sdk-starter-ruby's Issues

Preview curl not working

When running the curl

curl -X POST https://preview.twilio.com/Sync/Services \
 -d 'FriendlyName=MySyncServiceInstance' \
 -u 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_api_secret'

The following message was received

{"code": 20404, "message": "The requested resource /Sync/Services was not found", "more_info": "https://www.twilio.com/docs/errors/20404", "status": 404}%

Getting an error when running chat

I double checked and triple checked all my keys and everything looks good. Any ideas?

{
    "message": "The authorization with Token failed",
    "code": 2016,
    "user_error": false,
    "params": {
        "description": "Could not authenticate fpa token"
    }
}

twilio_chat_quickstart

Sample code for chat not working

I'm reviewing the sample Chat app

The Video conference is working, but the chat app is not. The app logs onto Twilio:

Logging in...
You have been assigned a random username of: terrance
Attempting to join "general" chat channel...

Then there is an error in the JavaScript console:

index.html:1 Uncaught (in promise) 
Object
body
:
Object
description
:
"Not Found"
status
:
404
__proto__
:
Object
__defineGetter__
:
__defineGetter__()
__defineSetter__
:
__defineSetter__()
__lookupGetter__
:
__lookupGetter__()
__lookupSetter__
:
__lookupSetter__()
constructor
:
Object()
hasOwnProperty
:
hasOwnProperty()
isPrototypeOf
:
isPrototypeOf()
propertyIsEnumerable
:
propertyIsEnumerable()
toLocaleString
:
toLocaleString()
toString
:
toString()
valueOf
:
valueOf()
get __proto__
:
__proto__()
set __proto__
:
__proto__()

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.