community.general.twilio (8.5.0) — module

Sends a text message to a mobile phone through Twilio

Authors: Matt Makai (@makaimc)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Sends a text message to a phone number through the Twilio messaging API.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# send an SMS about the build status to (555) 303 5681
# note: replace account_sid and auth_token values with your credentials
# and you have to have the 'from_number' on your Twilio account
- name: Send a text message to a mobile phone through Twilio
  community.general.twilio:
    msg: All servers with webserver role are now configured.
    account_sid: ACXXXXXXXXXXXXXXXXX
    auth_token: ACXXXXXXXXXXXXXXXXX
    from_number: +15552014545
    to_number: +15553035681
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# send an SMS to multiple phone numbers about the deployment
# note: replace account_sid and auth_token values with your credentials
# and you have to have the 'from_number' on your Twilio account
- name: Send a text message to a mobile phone through Twilio
  community.general.twilio:
    msg: This server configuration is now complete.
    account_sid: ACXXXXXXXXXXXXXXXXX
    auth_token: ACXXXXXXXXXXXXXXXXX
    from_number: +15553258899
    to_numbers:
      - +15551113232
      - +12025551235
      - +19735559010
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# send an MMS to a single recipient with an update on the deployment
# and an image of the results
# note: replace account_sid and auth_token values with your credentials
# and you have to have the 'from_number' on your Twilio account
- name: Send a text message to a mobile phone through Twilio
  community.general.twilio:
    msg: Deployment complete!
    account_sid: ACXXXXXXXXXXXXXXXXX
    auth_token: ACXXXXXXXXXXXXXXXXX
    from_number: +15552014545
    to_number: +15553035681
    media_url: https://demo.twilio.com/logo.png
  delegate_to: localhost

Inputs

    
msg:
    description:
    - The body of the text message.
    required: true
    type: str

media_url:
    description:
    - A URL with a picture, video or sound clip to send with an MMS (multimedia message)
      instead of a plain SMS.
    required: false
    type: str

auth_token:
    description:
    - User's Twilio authentication token.
    required: true
    type: str

to_numbers:
    aliases:
    - to_number
    description:
    - One or more phone numbers to send the text message to, format C(+15551112222).
    elements: str
    required: true
    type: list

account_sid:
    description:
    - User's Twilio account token found on the account page.
    required: true
    type: str

from_number:
    description:
    - The Twilio number to send the text message from, format C(+15551112222).
    required: true
    type: str