1. circleci/twilio@1.0.0

circleci/twilio@1.0.0

Certified
Sections
Create custom Twilio SMS notifications for CircleCI jobs. Check the linked API docs for further information. Requires "Option 2" environment variables to be created, as detailed here: https://www.twilio.com/docs/twilio-cli/general-usage#want-to-use-environment-variables-instead-of-creating-a-profile
Created: December 11, 2018Version Published: July 2, 2020Releases: 2
Org Usage:
< 25

Orb Quick Start Guide

Use CircleCI version 2.1 at the top of your .circleci/config.yml file.

1 version: 2.1

Add the orbs stanza below your version, invoking the orb:

1 2 orbs: twilio: circleci/twilio@1.0.0

Use twilio elements in your existing workflows and jobs.

Usage Examples

alert

This function is the same as the "sendsms" command but will only run when the job has failed. This must be the last step in a job to work properly.

1 2 3 4 5 6 7 8 9 10 11 12 13 orbs: jobs: build: docker: - image: cimg/node:14.4.0 steps: - twilio/install - twilio/alert: body: Customize alert message for this job from: '+15005550006' to: '+15005550006' twililo: circleci/twilio@volatile version: 2.1

send-sms

Send an SMS with a custom message.

1 2 3 4 5 6 7 8 9 10 11 12 13 orbs: jobs: build: docker: - image: cimg/base:edge steps: - twilio/install - twilio/sendsms: body: This is a custom message notification from: '+15005550006' to: '+15005550006' twililo: circleci/twilio@x.y.z version: 2.1

Commands

alert

Send SMS alert on failure only. This must be the last step in the job to work properly.

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
authtoken
API authorization token for your Twilio account.
No
TWILIO_AUTH_TOKEN
env_var_name
body
The Body parameter includes the full text of the message you want to send, limited to 1600 characters.
No
Notification from CircleCI. A critical test has failed.
string
from
This must be a Twilio phone number that you own, formatted with a '+' and country code, e.g. +16175551212 (E.164 format). You can also use a Messaging Service SID.
No
${TWILIO_FROM}
string
sid
Twilio account SID.
No
TWILIO_ACCOUNT_SID
string
to
This parameter determines the destination phone number for your SMS message. Format this number with a '+' and a country code, e.g., +16175551212 (E.164 format).
No
${TWILIO_TO}
string

install

Install the Twilio CLI from npm. Requires node - most commands will fall back to using curl requests if the CLI cannot be found.

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
version
Version of the Twilio CLI package to install. Defaults to latest.
No
latest
string

sendsms

Send SMS notifications using Twilio

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
authtoken
API authorization token for your Twilio account.
No
TWILIO_AUTH_TOKEN
env_var_name
body
The Body parameter includes the full text of the message you want to send, limited to 1600 characters.
No
Notification from CircleCI. You have not yet customized your message.
string
from
This must be a Twilio phone number that you own, formatted with a '+' and country code, e.g. +16175551212 (E.164 format). You can also use a Messaging Service SID.
No
${TWILIO_FROM}
string
sid
Twilio account SID.
No
TWILIO_ACCOUNT_SID
string
to
This parameter determines the destination phone number for your SMS message. Format this number with a '+' and a country code, e.g., +16175551212 (E.164 format).
No
${TWILIO_TO}
string

Orb Source

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 # This code is licensed from CircleCI to the user under the MIT license. # See here for details: https://circleci.com/developer/orbs/licensing commands: alert: description: Send SMS alert on failure only. This must be the last step in the job to work properly. parameters: authtoken: default: TWILIO_AUTH_TOKEN description: API authorization token for your Twilio account. type: env_var_name body: default: Notification from CircleCI. A critical test has failed. description: The Body parameter includes the full text of the message you want to send, limited to 1600 characters. type: string from: default: ${TWILIO_FROM} description: | This must be a Twilio phone number that you own, formatted with a '+' and country code, e.g. +16175551212 (E.164 format). You can also use a Messaging Service SID. type: string sid: default: TWILIO_ACCOUNT_SID description: Twilio account SID. type: string to: default: ${TWILIO_TO} description: | This parameter determines the destination phone number for your SMS message. Format this number with a '+' and a country code, e.g., +16175551212 (E.164 format). type: string steps: - run: command: | if type twilio > /dev/null; then twilio api:core:messages:create \ --body "<< parameters.body >>" \ --from "<< parameters.from >>" \ --to "<< parameters.to >>" else curl -X POST https://api.twilio.com/2010-04-01/Accounts/${<< parameters.sid >>}/Messages.json \ --data-urlencode "From=<< parameters.from >>" \ --data-urlencode "Body=<< parameters.body >>" \ --data-urlencode "To=<< parameters.to >>" \ -u ${<< parameters.sid >>}:${<< parameters.authtoken >>} fi name: Sending SMS when: on_fail install: description: | Install the Twilio CLI from npm. Requires node - most commands will fall back to using curl requests if the CLI cannot be found. parameters: version: default: latest description: Version of the Twilio CLI package to install. Defaults to latest. type: string steps: - run: command: | if ! type npm > /dev/null; then echo "npm is not installed, cannot install the Twilio CLI." echo "You can skip this step - commands will default to curl requests." exit 0 fi if [[ $EUID == 0 ]]; then export SUDO=""; else # Check if we're root if ! [[ -w "$(npm root -g)" ]]; then export SUDO="sudo"; fi fi $SUDO npm i -g twilio-cli@<<parameters.version>> name: Install Twilio CLI sendsms: description: Send SMS notifications using Twilio parameters: authtoken: default: TWILIO_AUTH_TOKEN description: API authorization token for your Twilio account. type: env_var_name body: default: Notification from CircleCI. You have not yet customized your message. description: The Body parameter includes the full text of the message you want to send, limited to 1600 characters. type: string from: default: ${TWILIO_FROM} description: | This must be a Twilio phone number that you own, formatted with a '+' and country code, e.g. +16175551212 (E.164 format). You can also use a Messaging Service SID. type: string sid: default: TWILIO_ACCOUNT_SID description: Twilio account SID. type: string to: default: ${TWILIO_TO} description: | This parameter determines the destination phone number for your SMS message. Format this number with a '+' and a country code, e.g., +16175551212 (E.164 format). type: string steps: - run: command: | if type twilio > /dev/null; then twilio api:core:messages:create \ --body "<< parameters.body >>" \ --from "<< parameters.from >>" \ --to "<< parameters.to >>" else curl -X POST https://api.twilio.com/2010-04-01/Accounts/${<< parameters.sid >>}/Messages.json \ --data-urlencode "From=<< parameters.from >>" \ --data-urlencode "Body=<< parameters.body >>" \ --data-urlencode "To=<< parameters.to >>" \ -u ${<< parameters.sid >>}:${<< parameters.authtoken >>} fi name: Sending SMS description: | Create custom Twilio SMS notifications for CircleCI jobs. Check the linked API docs for further information. Requires "Option 2" environment variables to be created, as detailed here: https://www.twilio.com/docs/twilio-cli/general-usage#want-to-use-environment-variables-instead-of-creating-a-profile display: home_url: https://www.twilio.com source_url: https://github.com/circleci-public/twilio-orb examples: alert: description: | This function is the same as the "sendsms" command but will only run when the job has failed. This must be the last step in a job to work properly. usage: orbs: jobs: build: docker: - image: cimg/node:14.4.0 steps: - twilio/install - twilio/alert: body: Customize alert message for this job from: "+15005550006" to: "+15005550006" twililo: circleci/twilio@volatile version: 2.1 send-sms: description: | Send an SMS with a custom message. usage: orbs: jobs: build: docker: - image: cimg/base:edge steps: - twilio/install - twilio/sendsms: body: This is a custom message notification from: "+15005550006" to: "+15005550006" twililo: circleci/twilio@x.y.z version: 2.1 version: 2.1
Developer Updates
Get tips to optimize your builds
Or join our research panel and give feedback
By submitting this form, you are agreeing to ourTerms of UseandPrivacy Policy.