Demo of communications functions
You can see all communications functions in action by running:
$ python -m f451-comms --msg "Hello world! :-)" --secrets _PATH_TO_SECRETS_
This will send a “Hello world!” message to all channels listed in the secrets.ini
or similar configuration file. And yes, in order for this to work, you’ll need to first set up accounts with all services (e.g. email, Slack, SMS, etc.) that you want to use.
The f451 Communications module currently supports the following services:
Note
Please review the documentation for each sub-module for additional information.
Warning
If API keys and other secrets are not properly defined in your configuration files, then the methods in the f451 Communications module will raise exceptions.
Sample secrets.ini file
It is recommended that you store API keys and other secrets in a separate configuration file. Also ensure that this file is excluded from any files uploads to source code repositories.
[f451_mailgun]
priv_api_key = _YOUR_PRIVATE_API_KEY_
publ_val_key = _YOUR_PUBLIC_API_KEY_
webhook_sign_key = _YOUR_WEBHOOK_SIGNING_KEY_
from_domain = _YOUR_DOMAIN_NAME_
[f451_slack]
auth_token = _YOUR_SLACK_AUTH_TOKEN_
app_token = _YOUR_SLACK_APP_TOKEN_
signing_secret = _YOUR_SLACK_SIGNING_SECRET_
[f451_twilio]
acct_sid = _YOUR_TWILIO_SID_
auth_token = _YOUR_TWILIO_TOKEN_
from_phone = _YOUR_TWILIO_FROM_PHONE_+15555550000
[f451_twitter]
user_key = _YOUR_TWITTER_USER_KEY_
user_secret = _YOUR_TWITTER_SECRET_KEY_
auth_token = _YOUR_TWITTER_AUTH_TOKEN_
auth_secret = _YOUR_TWITTER_AUTH_SECRET_
See section “Configuration files” for more information.
Running from CLI
f451-comms - CLI interface
Send messages via ‘f451 Communications’ [v0.1.1] module
f451-comms [-h] [-V] [-d] [--channel CHANNEL] [--msg MSG] [--secrets SECRETS]
[--config CONFIG] [--log LOG]
f451-comms options
--channel
CHANNEL
- Communications channel(s) to use (default:all
)--msg
MSG
- Text to send (default:Testing 'f451-comms' module -- <some random text>
)--secrets
SECRETS
- Path to primary config file (default:None
)--config
CONFIG
- Path to secondary config file (default:None
)--log
LOG
- Path to log file (default:None
)