Amazon SMS text message sending

Currently I use a simple python script to send an sms message to my mobile from my amazon aws account. I would like to be able to do this with either a dedicated node or a function node. I am not really sure how to go about this. The main reason is to send a heart beat every day at a set time.

import os
import boto3


client= boto3.client("sns", aws_access_key_id="*********************", aws_secret_access_key="**********************", region_name="eu-west-1")
client.publish(PhoneNumber="**************", Message="The Raspberry Pi Is Working")

Any ideas much appreciated.

You should be able to run the python script from an Exec node. Put in the full path to the python executable and to your script file. Use forward slashes in paths even if using Windows.

1 Like

So in the command i have added sudo python3 /home/johnmholmes/Text.py and added a trigger node but I see error 1 when I try to trigger it. Not sure about the executable.

Why have you used sudo? You will need to do some additional stuff if it needs sudo.

Use which python to find the path to python. Possibly /usr/bin/python.

When you get an error in the exec node add debug nodes to all outputs, set them to Output Complete Message (that is important) and check all the contents of the messages. Somewhere there will probably be an error message.

1 Like

Sorry Colin I have been trying different things to see if I could get it to work.

changed it and its now working so thanks for the help.

It is possible to store your python code within Node-red, which perhaps helps keep your Node-red system less cluttered up with external scripts.
Here is an example

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.