Skip to content

Commit

Permalink
feat(script editor): add opt out language warning (#1436)
Browse files Browse the repository at this point in the history
Reviewed-by: @bchrobot
Reviewed-by: @hiemanshu
  • Loading branch information
ajohn25 authored Sep 28, 2022
1 parent d614427 commit f2127da
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/components/ScriptEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ interface Props {
scriptText: string;
scriptFields: string[];
campaignVariables: CampaignVariable[];
isRootStep: boolean;
integrationSourced: boolean;
onChange: (value: string) => Promise<void> | void;
receiveFocus?: boolean;
Expand Down Expand Up @@ -320,6 +321,38 @@ class ScriptEditor extends React.Component<Props, State> {
}
}

renderOptOutLanguageWarning() {
const lowercaseText = this.state.editorState
.getCurrentContent()
.getPlainText()
.toLowerCase();

// 2022-09-24 - stop as a separate word is best for avoiding spam blocks
if (
this.props.isRootStep &&
lowercaseText.length > 0 &&
!lowercaseText.includes("stop ")
)
return (
<div style={{ color: baseTheme.colors.red }}>
<br />
WARNING! This script does not include opt out language. You must let
the recipient know they can opt out of receiving future texts, or your
messages are very likely to be blocked as spam. We recommend a phrase
with the individual word STOP, such as "Reply STOP to quit." Please
see our{" "}
<a
href="https://docs.spokerewired.com/article/168-spoke-101-tips-for-a-successful-mass-text"
target="_blank"
rel="noopener noreferrer"
>
deliverability checklist
</a>{" "}
for other best practices for improving deliverability.
</div>
);
}

renderCustomFields() {
const { scriptFields, campaignVariables } = this.props;
return (
Expand Down Expand Up @@ -376,6 +409,7 @@ class ScriptEditor extends React.Component<Props, State> {
{this.renderCustomFields()}
<div>
{this.renderAttachmentWarning()}
{this.renderOptOutLanguageWarning()}
<br />
Estimated Segments: {info.msgCount} <br />
Characters left in current segment:{" "}
Expand Down
3 changes: 3 additions & 0 deletions src/components/forms/GSScriptOptionsField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class GSScriptOptionsField extends GSFormField {
name,
customFields,
campaignVariables,
isRootStep,
value: scriptVersions,
integrationSourced,
orgSettings
Expand Down Expand Up @@ -154,6 +155,7 @@ class GSScriptOptionsField extends GSFormField {
scriptFields={scriptFields}
campaignVariables={campaignVariables}
integrationSourced={integrationSourced}
isRootStep={isRootStep}
receiveFocus
expandable
onChange={(val) => this.setState({ scriptDraft: val.trim() })}
Expand Down Expand Up @@ -230,6 +232,7 @@ GSScriptOptionsField.propTypes = {
value: PropTypes.string
})
).isRequired,
isRootStep: PropTypes.bool.isRequired,
name: PropTypes.string,
className: PropTypes.string,
hintText: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export const InteractionStepCard: React.FC<Props> = (props) => {
hintText="This is what your texters will send to your contacts. E.g. Hi, {firstName}. It's {texterFirstName} here."
customFields={customFields}
campaignVariables={campaignVariables}
isRootStep={isRootStep}
integrationSourced={integrationSourced}
fullWidth
multiLine
Expand Down

0 comments on commit f2127da

Please sign in to comment.