Adding the SMS Addon

📘

Note

The SMS Addon will opt-in the subscription to SMS Messages.

Updating a subscription's SMS Addon will automatically send an opt-in SMS message to the phone number using the Twilio Integration Messaging Service configured in your OptiPub installation.

The <optipub-subscribe> element can optin subscribers to the SMS Addon as well.

To use the SMS Addon, the variable name phone must first be created in Variables with the variable type Text.

To add a phone number to the SMS Addon of a subscription add these inputs to the element:

<input type="tel" name="phone" placeholder="Phone Number">
<input type="hidden" name="enable_addon" value="SMS">

Review the HTML Examples below for SMS Addon.

SMS Addon for Existing Subscriptions

To obtain phone numbers from existing subscribers only, add this hidden input:

<input type="hidden" name="existing_subscription" value="[any value]">

The value for this input will be ignored, but one must be provided. Use "true" or "foo" or anything else will work.

Considerations when using the existing_subscription input

This input will prevent triggering a duplicate subscription event when adding an SMS Addon phone number to an existing subscription.

Form submissions will fail for email addresses without an existing subscription for the publication, when using this input. It's important to customize the error-alert slot or else a generic unprocessable entity error will display on submission failure.

Review the HTML Examples below for Existing Subs.


HTML Examples

<optipub-subscribe class="form-container" publication-id="1" effort-id="123"> 
  <template v-slot:input-group>
    <h2>Subscribe to OptiPub</h2>
    <input type="email" name="email" placeholder="Email" required>
    <input type="tel" name="phone" placeholder="Phone Number" required>
    <input type="hidden" name="enable_addon" value="SMS">
    <button type="submit">Subscribe Now!</button>
    <p>
      *I agree to receive recurring automated promotional text messages from OptiPub at the
      phone number provided. Message and data rates apply. Reply STOP anytime to stop receiving
      text messages. Message frequency varies.
    </p>
  </template>
  <template v-slot:success-alert>
    <div class="popup success">
      <span>Subscribed Successfully!</span>
    </div>
  </template>
</optipub-subscribe>
<optipub-subscribe class="form-container" publication-id="1" effort-id="7"> 
  <template v-slot:input-group>
    <h2>Subscribe to OptiPub SMS Text Alerts</h2>
    <input type="email" name="email" placeholder="Email" required>
    <input type="tel" name="phone" placeholder="Phone Number" required>
    <input type="hidden" name="enable_addon" value="SMS">
    <input type="hidden" name="existing_subscription" value="true">
    <button type="submit">Subscribe to SMS Alerts</button>
    <p>
      *I agree to receive recurring automated promotional text messages from OptiPub at the
      phone number provided. Message and data rates apply. Reply STOP anytime to stop receiving
      text messages. Message frequency varies.
    </p>
  </template>
  <template v-slot:success-alert>
    <div class="popup success">
      <span>Thank you for signing up to OptiPub SMS text alerts!</span>
    </div>
  </template>
  <template v-slot:error-alert>
    <div class="popup error">
      <span>You must have an existing active subscription.</span>
    </div>
  </template>
</optipub-subscribe>

📘

Landing Pages

In Landing Pages use the macro {$effort_id} for the effort-id value in the optipub-subscribe element.

<optipub-subscribe publication-id="1" effort-id="{$effort_id}">