A simple serverless app to receive a webhook from Nexmo's SMS Service and respond with a fortune from Ubuntu's excellent collection of fairly silly fortune cookies.
For the full blog post, look here: https://www.nexmo.com/blog/2018/08/14/serverless-sms-nexmo-ibm-dr/
You'll need this to receive SMS messages - set up incoming number before you start.
Set the variables NEXMO_API_KEY and NEXMO_API_SECRET to the relevant values for your account. Also set NEXMO_NUMBER to the number you bought in step 1 (we'll use it as the from number).
Before deploying a function for the first time, create the package:
ibmcloud fn package update sms-fortune -p apikey $NEXMO_API_KEY -p apisecret $NEXMO_API_SECRET -p nexmonumber $NEXMO_NUMBER
Each language has a deploy.sh
file in its folder, run this script (I mean, read the script so you know what's happening: it zips all the dependencies and deploys the result)
First we need to ask the serverless function what URL it has:
ibmcloud fn action get --url sms-fortune/incoming-php
Now paste that into the settings screen on your Nexmo dashboard.
OR
Configure from the command line instead:
nexmo link:sms [number] [url]
Send an SMS (with any content) to the number you set up and laugh at the daft message you get back :)