Download OpenAPI specification:Download
This Docker container provides a simple API for sending alerts via SMS, Slack, or Microsoft Teams. It can be run as a local service or deployed as part of a full pipeline using PHDI Building Blocks as in CDCgov/phdi-azure.
Some manual steps need to be taken to enable alerts in your particular environment.
In order to send text messages, you'll need to create an Azure Communication Service. Follow this quickstart guide to set up the resource. Once created, you'll need to provide the name of your resource as an environment variable (COMMUNICATION_SERVICE_NAME
) to the container.
The first time you make a call to /sms-alert
, the container will purchase a phone number to use for sending text messages. This will charge your Azure account $2/month to reserve the phone number.
Support for other SMS providers besides Azure are coming soon!
POST /sms-alert
{
"phone_number": "+19168675309",
"message": "Hi this is a test"
}
To send alerts to your Slack workspace, you'll need to create a Slack application. Follow this guide to create the Slack app, giving it a name you'll recognize, such as PHDI Alerts
. The OAuth access token must be provided to the container as an environment variable (SLACK_BOT_TOKEN
). You must also invite the application to any channel you wish to alert (type /invite
in the channel and choose "Add apps to channel"). To get the ID of a channel, right click the channel name and choose "View channel details". The ID is at the bottom of the modal that appears.
POST /slack-alert
{
"channel_id": "C04GKBFMGRM",
"message": "Hi this is a test"
}
To send alerts to Microsoft Teams, you'll need to create a webhook in the channel you wish to alert. To add an incoming webhook to a Teams channel:
Provide this URL as an environment variable (TEAMS_WEBHOOK_URL
) to the container.
POST /teams-alert
{
"message": "Hi this is a test"
}
Send an SMS alert to a phone number. :param input: A JSON formated request body with schema specified by the SmsAlertInput model.
phone_number required | string (Phone Number) The phone number to send the alert to. |
message required | string (Message) The message to send to the phone number. |
{- "phone_number": "string",
- "message": "string"
}
null
Send a Slack alert to a channel. :param input: A JSON formated request body with schema specified by the SlackAlertInput model.
channel_id required | string (Channel Id) The Slack channel ID to send the alert to. |
message required | string (Message) The message to send to the Slack channel. |
{- "channel_id": "string",
- "message": "string"
}
null
Send a Teams alert to a channel. :param input: A JSON formated request body with schema specified by the TeamsAlertInput model.
message required | string (Message) The message to send to the Teams channel. |
{- "message": "string"
}
null