Text Messages

This section describes how to configure Dari for sending text messages.

Step 1: Acquire SMS API Credentials

This section provides the basic steps to acquire an SMS API key from Twilio. Acquiring API credentials for other messaging services is similar.

  1. In your browser, go to https://www.twilio.com/ and click Get a free API key.

  2. In the Sign up for free page, enter your account information and then click Get Started.

    ../../_images/twilio-signup.png
  3. In the verification page, enter your phone number and click Verify via SMS.

    ../../_images/twilio-verify.png
  4. In the following response page, enter the verification code you received from Twilio and click Submit.

    ../../_images/twilio-submit-verification-code.png
  5. Fill out any subsequent forms until you get to the dashboard.

  6. In the dashboard’s upper-right corner, click Show API Credentials.

    ../../_images/twilio-show-api-credentials.png
  7. Copy the values for ACCOUNT SID and AUTH TOKEN into a text editor.

Step 2: Provision From Numbers

In this step, you provision phone numbers from which Twilio can send text messages.

  1. Navigate to the Twilio dashboard, and click Manage Numbers. The Phone Numbers Dashboard appears.

    ../../_images/twilio-phone-numbers-dashboard.png
  2. Click Get Started, and in the next page click Get your first Twilio phone number. A widget appears.

    ../../_images/twilio-first-phone-number.png

    Referring to the previous illustration, the Twilio phone number is (202) 816-4833.

  3. Click Choose this Number. A confirmation widget appears.

    ../../_images/twilio-confirmation-widget.png
  4. Copy the phone number into a text editor. Referring to the previous illustration, the phone number you copy is +12028164833.

Step 3: Configure Dari for Text Messaging

In this step, you configure Dari to send text messages using the API credentials you acquired in Step 1: Acquire SMS API Credentials and the phone number you acquired in Step 2: Provision From Numbers.

  1. In a text editor, open the Tomcat configuration file conf/context.xml.

  2. Add the following lines:

    1
    2
    3
    4
    5
    6
    <!-- SMS -->
    <Environment name="dari/defaultSmsProvider" override="false" type="java.lang.String" value="twilio" />
    <Environment name="dari/smsProvider/twilio/class" override="false" type="java.lang.String" value="notifications.TwilioSmsProvider" />
    <Environment name="dari/smsProvider/twilio/accountSid" override="false" type="java.lang.String" value="putYourAccountIDHere" />
    <Environment name="dari/smsProvider/twilio/authToken" override="false" type="java.lang.String" value="putYourAuthTokenHere" />
    <Environment name="dari/smsProvider/twilio/defaultFromNumber" override="false" type="java.lang.String" value="+12028164833" />
    
  3. Save and close the configuration file.

  4. Restart the Tomcat server.

In the previous snippet—

  • Line 2 specifies the default text messaging configuration as twilio.
  • Line 3 specifies the fully qualified class name implementing the text messaging service.
  • Lines 4–5 include values for the messing API’s account ID and token that you acquired in Step 1: Acquire SMS API Credentials.
  • Line 6 specifies the default from number that appears in the recipient’s text message. This number must be one that the SMS service recognizes as authorized to send text messages, and is the same one you created in Step 2: Provision From Numbers.