Real-time, multi-user chat interface for SMS / text messages. Imagine a call center where customers can send a text message to a single number and have a live chat with any agent(s) available.
- Clone this repo using
git clone https://github.com/timwis/enviar.git
- Install node dependencies via
npm install
- Copy
.env.sample
to.env
This application uses CouchDB to store messages. Follow their install docs to run CouchDB locally or setup a free hosted instance with CloudAnt.
- Fill in your the
COUCHDB_HOST
in.env
(ie.http://localhost:5984
) - By default, couchdb considers everyone an admin. If you have disabled this setting (recommended for production)
and have an admin user setup, fill in its credentials in the
COUCHDB_USER
andCOUCHDB_PASS
variables. Otherwise continue without these. - Configure the database using
npm run bootstrap
. If you're running couchdb locally, also runnpm run cors
.
- Run the server using
NODE_ENV=development npm start
- Access the server at
http://localhost:3000
You can simulate sending messages using the interface. To simulate receiving a message,
send a POST
request to http://localhost:3000/api/inbound
.
Sample inbound POST
request: (note the +
in the phone number is encoded as %2B
)
curl -X POST -d 'SmsSid=123456&From=%2B12597150948&Body=hello' http://localhost:3000/api/inbound
- Fill in your twilio credentials in
.env
- Run the server using
npm start
- Point twilio's incoming message webhook to
http://<your-server>/api/inbound
(check out ngrok to expose your localhost)
Access the server at http://localhost:3000
By default, couchdb considers everyone an admin. If you have disabled this setting (recommended for production)
and have created an admin user, you can use that user to login to enviar. You can also create users that have
agent
-level access, allowing them to user enviar without admin access. To create agent
users, use the
command line interface.
To create a user or change a user's password
npm run user -- <username> <password>
To "upgrade" an existing user to have agent
access, simply omit the password.
npm run user -- <username>
This functionality will eventually be incorporated into the application.