Did you ever want to text your friend but you are always busy :D or just not comfortable with your phone small screen .... Now you can text anyone at anytime without even holding your phone or type a single letter with Alexa Messenger. You just:
Ask Messenger to send "your friend" "the message you want"
Yes it is that simple and you do not have to leave what you are doing and hold the phone.
How is that:
The messenger is built by using AWS Lambda, AWS IoT, Rasspery Pi..
Don't worry if you are new to these terms we will talk about each one by one.
So let's start with ASK or (Alexa Skill kit):
1. Create aws acount from this link : http://aws.amazon.com
2. Log into AWS Console and select Lambda.
3. Click on "Create a Lambda" function as below.
4. Go the bottom of the page and click “Skip”.
5. Name Lambda function any name you want.
6. Leave runtime as Node.js and select “Edit Code Inline” - we will actually upload our code using a script later. In the code block, just put a comment like:
// nothing here yet
7. Use Basic Execution Role, it will pop up a new window create a new, IAM role, it and choose lambda_basic_execution
8. Click “Allow” on bottom of the page Leave other defaults except Timeout, increase to 10 seconds. Then click “Next”.
Click "create function"
9. Note your Lambda function’s ARN (Amazon Resource Name) on the top right. It will look like - arn:aws:lambda:us-east- etc etc etc… Copy this, because you will need to supply this to Alexa Skill configuration in a later step.
10. IMPORTANT : Select “Event Sources” tab and “Add event source”. Select Amazon Skills Kit, and save. without this you will get an error later linking your lambda function to skill in developer console.
We will upload the zip file later.
now leave this page open and open Aws Iot service.
Create resource and click "create a thing".
Name it Messenger.
Then create a certificate with 1 click certificate and download all 3 certificates.
Now attach the thing called messenger to your certificate from actions menu.
Choose the thing called Messenger and click attach.
Now we will create a policy to allow interaction with the thing we created.
For this demo we will let the policy allow everything.
Tick allow , click add statement, and then click create.
Now you should be able to see the details of the policy you just created.
Let's now Set up the Raspberry Pi
I am using Raspberry Pi 3 however any Raspberry pi can be used in this tutorial.
First we need to install yowsub library from github.
Update the packages with.
sudo apt-get upgrade
Prepare the system with the necessary components to Yowsup.
sudo apt-get install python-dateutil sudo apt-get install python-setuptools sudo apt-get install python-dev sudo apt-get install libevent-dev sudo apt-get install ncurses-dev
Download the library with the command.
git clone git://github.com/jlguardi/yowsup
Navigate to the folder.
And install the library with the command.
sudo python setup.py install
note if error occured here with something like disable-jpeg
write the following command
sudo apt-get install
Then run setup again.
After installing the library we have to register the device to use WhatsApp.
First you need to request a registration code.
python yowsup-cli registration --requestcode sms --phone 39xxxxxxxxxx --cc 39 --mcc 222 --mnc 10
you can find your specific country code , mcc , mnc online from this link :
and replace the command with your data then You should receive on your phone a sms message with a code like xxx-xxx
Send a message to request registration with this command, (replace xxx-xxx with code you received)
python yowsup-cli registration --register xxx-xxx --phone 39xxxxxxxxxx --cc 39
If all goes well, we should get a message like this
status: ok kind: free pw: xxxxxxxxxxxxxxxxxx= price: € 0,89 price_expiration: 1416553637 currency: EUR cost: 0.89 expiration: 1445241022 login: 39xxxxxxxxxxx type: existing
WhatsApp requires the registration of a number, and with that number you can use WhatsApp on only one device at a time
WhatsApp can be used on one device at a time and if you will make many attempts to register the number, it could be banned.
Create a file to save your credentials.
sudo nano /home/pi/yowsup/config
With this content.
## Actual config starts below ## cc=39 #if not specified it will be autodetected phone=39xxxxxxxxxx password=xxxxxxxxxxxxxxx=
Ok, we're ready for the test, Yowsup has a demo application in /home/pi/yowsup/yowsup/demos
Navigate to yowsup folder.
Start yowsup-cli demos with the command.
yowsup-cli demos --yowsup --config config
You can see Yowsup prompt.
If type "/help" you can see all available commands.
First use the '/L' command for login; to send a message type.
/message send 39xxxxxxxxxx "This is a message sent from Raspberry Pi"
Replace xxx with the recipient number
And IT WORKED
Now we Know that the library is working but we need to link it to Iot !?
Look at the scheme below:
What is happening is that user ask alexa to send message to friend then alexa update aws iot shadow device with both "name" and "message" then rasperry pi will subscribe to shadow updates to get these values and send them throught the library the same way we did above and the script on rasperry pi will handle linking iot to the library :D easy, Right?
Place certificate files downloaded from aws IoTand this certificate from here:
Into same directory as yowsup-cli and also python file from source code provided in raspberry pi folder on github.
You need to modify the certificate names in the script , the host and mqtt topic you will find all these data on aws IoT as described before.
You will also need update the script with your own contact list.
Finally we need to develop our skill so this is my skill it is still in certification
This is the app id you need to update in lambda function.
Then we define Intent scheme and sample utterance as follow.
Take note of your ARN we mentioned above and paste it here.
Update the description. Example phrases and skill icon.
Then submit for certification,
Run piwhats.py and ask echo device to send message and see the MAGIC :D