Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(script editor): add opt out language warning #1436

Merged
merged 2 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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