Giter VIP home page Giter VIP logo

smshub's Introduction

What does this do?

This app is responsible for managing all the login and messages for zipwhip for the Broadsoft Montreal hackathon for 2017. Zipwhip api docs can be found in the /docs folder. There is a free account you can get for zipwhip if you email them here: https://www.zipwhip.com/freetrial/

This app also stores all the data in a mongoLab database. This includes all messages sent from users to users as well as the phone numbers and names of contacts. We also currently store the hubLoginToken and the session for each zipWhip user.

Other apps that use this code

hubJavaStarter handles all interactions with the hub api SMS-UI handles rendering of the ui

How to create a hub app with this in the dev portal

Coming soon!

Routes

GET /test

Description: A url to test if the app is running and working

response:

'Hello!'

POST /login

Description: This logs the user into zipwhip and stores their session in the DB. This only needs to be called once per user but it can be called as many times as you wish.

Post Body:

{
  username: '5554443333',
  hubLoginToken: 'token',
  password: 'theUserPassword'
}

response: 200

POST /sendMessage

Description: This sends a message from one user to another.

Post Body:

{
  from: '5554443333',
  to: '6665558888',
  message: 'Hey buddy!'
}

response: 200

POST /createWebhook

Description: you need to call this to receive any messages. Pass in the url that you want to be called each time a message is received. When that url is called, you will need to read the response property to see the actual message.

Post Body:

{
  url: 'https://www.mydomain.com/handleWebhook', //You can call it any route you want
  username: '5554446666', //the phone number of the person you are calling
}

response: 200

GET /getCountForUser?token=hubLoginToken

Description: Returns the number of unread messages for the user. The token is the identifier of the user and it has to be the same hubLoginToken you passed in the /login route.

response: 200, {count: 11}

GET /getMessages?from=5554447777&to=8887774444

Description: Returns all the messages between the two users

response: 200

[
    {
        "_id": "59133715e7af9c72ad496c40",
        "from": "8445971754",
        "to": "5062062704",
        "message": "Hello",
        "isRead": false,
        "createdAt": "2017-05-10T15:51:49.457Z"
    },
    {
        "_id": "59134324e7ca8780c5ae89e8",
        "from": "8445971754",
        "to": "5062062704",
        "message": "This is a newer message",
        "isRead": false,
        "createdAt": "2017-05-10T16:43:16.863Z"
    }
]

POST /contact

Description: Create a contact for a user

Post Body:

{
  firstName: 'Jonathan',
  lastName: 'ODonnell',
  avatar: 'http://img.myimage.com/catAvatar', (optional)
  phoneNumber: '8889990000', // the contact's phone number
  username: '5554446666', // the phone number of the user
}

response: 200

GET /contacts?username=8885556666

Description: Get all the user contacts

response: 200

[
    {
        "_id": "59148fec778a8f77b848790c",
        "firstName": "Jon",
        "lastName": "ODonnell",
        "avatar": "",
        "phoneNumber": "7778889999",
        "username": "8885556666"
    },
    {
        "_id": "591490229c3b75780aaffbf0",
        "firstName": "Jon",
        "lastName": "ODonnell",
        "avatar": "",
        "phoneNumber": "7778889999",
        "username": "8885556666"
    },
    {
        "_id": "591490317cd06f783e441d75",
        "firstName": "Jon",
        "lastName": "ODonnell",
        "avatar": "",
        "phoneNumber": "7778889999",
        "username": "8885556666"
    }
]

Data Model

user

  • username (can be phone number)
  • session (the zip whip session)
  • hubLoginToken
  • createdAt

contact

  • firstName
  • lastName
  • avatar
  • phoneNumber
  • user
  • createdAt

message

  • from (the number the message was sent from)
  • to (the number the message was sent to)
  • message (the text of the message)
  • isRead (has the user viewed the message)
  • createdAt

TODO

  • tests
  • Make it secure
  • make all db calls return promises

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.