https://www.CloudNewman.Me was one of the projects I created for the Postman API Hackathon. CloudNewman.me is a http API that invokes a Postman collection; allowing you to have your collection invoked as part of a webhook.
Newman (https://github.com/postmanlabs/newman) is a command-line collection runner for Postman. There is also a Newman library that can be invoked from JavaScript -- this is the library is utilized by CloudNewman.me.
Postman has the concept of a Collection (a series of web requests + scripts) that can be chained together to create useful requests. It also has the concept of an Environment (which are a set of variables that can be accessed by the requests and the scripts. CloudNewman.me allows you to pass your public environment, private environment and collection to be invoked.
Sample usage: I created a Vonage account (and configured incoming SMS messages to have an Inbound URL) - https://www.cloudnewman.me/v1?radius=200&apikey=<postmanApiKey PMAC-...>&collectionuid=10412913-d7ec94c1-c66d-44ba-8b1c-82e132ff824a&environmentuid=13458777-f3119f69-08c1-422f-a1ed-e8f0b5e410d3. When you send an SMS message to the number, the collection is invoked with the specified (private environment). The first request in the collection gets the phone number of the sender (msisdn) and the text message (text). The script processes the value in the text variable (in our case setting the starting point, ending point, and term to use for CoinStop.) At the end of the collection we reply with a text message by doing a POST to https://rest.nexmo.com/sms/json and in the body we specify the vonage api_key, api_secret, to (with the msisdn variable), from (with our vonage number) and text (with the message we want to send -- in our case a link to the dropbox document with the search results).
CloudNewman.me service is an Express app. The CloudNewman/app.js file has a function that parses the incoming request and sets a JSON request object (jsonBody).
To debug the parser, I used www.ngrok.com to create an endpoint, pointed Vonage at this endpoint and then ran ngrok and the express app on my local PC. Sending an SMS message resulted in the request traffic getting set to the local pc, via ngrok. While ngrok is running you can also go to http://127.0.0.1:4040 and see detailed information about the request.
Commentaires