An API server to demo how to use Nexmo In-App Messaging on your server-side applications. For more info visit our developer preview site.
Remix a sample project we set up on Glitch:
$ npm install -g nexmo-cli@beta
Setup the CLI to use your Nexmo API Key and API Secret. You can get these from the setting page in the Nexmo Dashboard.
$ nexmo setup api_key api_secret
Create an application named My Conversation Application
and store the returned private key as private.key
within your current working directory.
$ nexmo app:create "My Conversation Application" http://example.com http://example.com --type=rtc --keyfile=private.key
- Clone or download this repo
- Create a .env file using the env.example template
- Input your API Key, API Secret, and application ID
- Ensure the
private.key
file from the "Create an Application" is in your current working directory (Seeprivate.key.example
) - Install the node modules
$ npm install
- Start the app:
$ DEBUG=myapp:* npm start
- The app should be running on
localhost:3000
- Create a user or two
curl --request POST \
--url http://localhost:3000/users \
--header 'content-type: application/json' \
--data '{
"username": "user2",
"admin": true
}'
- Create a conversation via the gateway demo API
curl --request POST \
--url http://localhost:3000/conversations \
--header 'content-type: application/json' \
--data '{"displayName": "My Chat"}'
- Join the user to the conversation. Remember to replace the
conversationId
anduserId
with IDs from the two previous steps.
curl --request PUT \
--url http://localhost:3000/conversations \
--header 'content-type: application/json' \
--data '{
"conversationId": "CON-7cda3a42-8f7f-44c6-a4ba-aa23be506397",
"userId": "USR-ca160eee-836a-4ec7-8ac4-317aefe8d5d3",
"action": "join"
}'
- Verify the app is running by visiting
localhost:3000/users
You should see a json object containing the user(s) you created in step 1.
Use the Android Messaging Demo app and the JavaScript Messaging Demo app to try out Nexmo In-App Messaging across web and Android platforms.