This is a JavaScript project that creates a HTTP server for the Vonage Conversation API. This project was built to be used with an accompanying app, learn more about both projects on our blog.
A Swift version of this server is available on GitHub.
If you're new to Vonage, you can sign up for a Vonage API account and get some free credit to get you started.
-
NPM
-
Node
You can open the project on Glitch and the project will be deployed for you.
Add your private.key
file to the root folder.
Add your Vonage Application ID to the new .env
file.
After cloning the project to your machine change into the project directory.
Install the dependencies with npm install
.
Copy the .env.example file to a new .env file with cp .env.example > .env
and add your Vonage Application ID to the new .env
file.
Add your private.key
file to the root folder.
Once done, run node server.js
and the server will be accessible on port 3000.
The project serves to 3 endpoints:
/auth
(POST):
This returns a JWT to log the Client SDK in.
Request Body:
{
"name": "value" // String - username
}
Request Reponse:
{
"name": "value", // String - username
"jwt": "value" // String - JWT for the username
}
/rooms
(GET):
This returns a list of open chat rooms.
Request Reponse:
[
{
"id": "value", // String - ID for the room/conversation
"display_name": "value" // String - Name for the room/conversation
},
{
"id": "value", // String - ID for the room/conversation
"display_name": "value" // String - Name for the room/conversation
}
]
/rooms
(POST):
This allows the app to create a new room.
Request Body:
{
"display_name": "value" // String - Name for the room/conversation
}
Request Reponse:
{
"id": "value" // String - ID for the room/conversation
}
We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:
- Open an issue on this repository
- Tweet at us! We're @VonageDev on Twitter
- Or join the Vonage Developer Community Slack
- Check out the Developer Documentation at https://developer.nexmo.com