service-de-channel-consent-configure
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConfiguring Channel Consent
配置渠道同意机制
What this skill does
此功能的作用
Ensures an Enhanced has valid consent configured before activation. Consent has two parts, and both are checked by the server-side activation-readiness gate ():
MessagingChannelMessagingChannelReadinessChecker.isConsentConfiguredForChannel-
Channel-level fields on:
MessagingChannel- — static enum:
ConsentType,ImplicitOptIn, orExplicitOptIn.DoubleOptIn - — message sent when an end-user reply doesn't match an opt-in keyword (required for ExplicitOptIn/DoubleOptIn, except on Unified SMS / WhatsApp / RCS where it's optional).
OptInPrompt - — message sent when a reply doesn't match a double-opt-in keyword (required for DoubleOptIn).
DoubleOptInPrompt - — boolean flag; set true alongside
IsRequireDoubleOptIn.ConsentType=DoubleOptIn
-
Per-language keyword records — one or morechild rows (master-detail to
MsgChannelLanguageKeyword, key prefixMessagingChannel). Each holds the keywords an end-user sends (opt-in, double-opt-in, opt-out, help, custom) and the confirmation replies, for one language. Keyword fields are comma-separated strings (e.g.3Or)."STOP,UNSUBSCRIBE,CANCEL"
Consent is never a no-op for activation. Even requires at least one with an opt-out keyword + opt-out confirmation. (The one exception is an outbound-only channel, which the readiness check passes automatically.)
ImplicitOptInMsgChannelLanguageKeywordConsent settings apply only to Enhanced channels () of a supported message type. On a Standard channel these fields aren't used; this skill only touches Enhanced channels.
PlatformType=Enhanced确保增强型在激活前已配置有效的同意机制。同意机制包含两部分内容,服务器端的激活就绪校验()会对这两部分进行检查:
MessagingChannelMessagingChannelReadinessChecker.isConsentConfiguredForChannel-
的渠道级字段:
MessagingChannel- ——静态枚举值:
ConsentType、ImplicitOptIn或ExplicitOptIn。DoubleOptIn - ——当终端用户回复与选择加入关键词不匹配时发送的消息(ExplicitOptIn/DoubleOptIn类型必填,但在Unified SMS/WhatsApp/RCS渠道中为可选)。
OptInPrompt - ——当回复与双向确认加入关键词不匹配时发送的消息(DoubleOptIn类型必填)。
DoubleOptInPrompt - ——布尔标志;需与
IsRequireDoubleOptIn同时设为true。ConsentType=DoubleOptIn
-
按语言划分的关键词记录——一条或多条子记录(与
MsgChannelLanguageKeyword为主从关系,键前缀为MessagingChannel)。每条记录对应一种语言,存储终端用户发送的关键词(选择加入、双向确认加入、选择退出、帮助、自定义)及确认回复。关键词字段为逗号分隔的字符串(例如3Or)。"STOP,UNSUBSCRIBE,CANCEL"
同意机制对激活而言并非可有可无。即使是类型,也至少需要一条包含选择退出关键词+选择退出确认消息的记录。(唯一例外是仅 outbound 的渠道,此类渠道会自动通过就绪检查。)
ImplicitOptInMsgChannelLanguageKeyword同意设置仅适用于支持消息类型的增强型渠道()。标准渠道不会使用这些字段;此功能仅针对增强型渠道生效。
PlatformType=EnhancedWhere this fits
适用场景
This skill runs between routing and activation in the Enhanced-channel setup pipeline. sets the channel's ; this skill configures consent; then flips the channel live. The activation readiness check requires both routing and consent, so run this before activating. The orchestrator sequences all three automatically — invoke this skill directly only when you want to configure consent on its own.
service-de-channel-routing-configureSessionHandlerservice-de-channel-activateservice-de-headless-channel-configure此功能在增强型渠道设置流程中的路由配置与激活步骤之间运行。负责设置渠道的;此功能负责配置同意机制;随后将渠道正式启用。激活就绪检查要求同时完成路由与同意配置,因此请在激活前运行此功能。编排器会自动按顺序执行这三个步骤——仅当您需要单独配置同意机制时,才直接调用此功能。
service-de-channel-routing-configureSessionHandlerservice-de-channel-activateservice-de-headless-channel-configureReference File Index
参考文件索引
| Reference file | Load when |
|---|---|
| Creating or updating the per-language |
| Troubleshooting an unexpected result, or before modifying this skill. |
| You want a reference run of the ImplicitOptIn, ExplicitOptIn, or DoubleOptIn paths. |
| 参考文件 | 加载时机 |
|---|---|
| 创建或更新按语言划分的 |
| 排查异常结果或修改此功能之前。 |
| 需要参考ImplicitOptIn、ExplicitOptIn或DoubleOptIn流程的运行示例时。 |
When NOT to use this skill
不适用场景
- The channel isn't Enhanced. Consent fields apply to Enhanced channels only. This skill confirms and stops otherwise.
PlatformType=Enhanced - The channel is outbound-only. Outbound-only channels pass the consent-readiness check automatically; there's nothing to configure.
- The channel doesn't exist yet. Run the insertion skill first; this skill expects a real .
MessagingChannel.Id
- 渠道非增强型:同意字段仅适用于增强型渠道。此功能会先确认,否则将停止运行。
PlatformType=Enhanced - 渠道仅支持 outbound:仅outbound的渠道会自动通过同意就绪检查,无需进行任何配置。
- 渠道尚未创建:请先运行渠道创建功能;此功能需要已存在的。
MessagingChannel.Id
Inputs (from caller)
调用方输入参数
- — a 15- or 18-char
{CHANNEL_ID}(prefixMessagingChannel.Id). Must already exist and be Enhanced.0Mj - — optional; one of
{CONSENT_TYPE}|ImplicitOptIn|ExplicitOptIn. If omitted, the skill prompts.DoubleOptIn - — optional; the
{LANGUAGE}for the keyword record (e.g.MasterLanguage). Defaults toen_USif not provided.en_US - — optional;
{ORG_ALIAS}CLI target-org alias. Default: whateversfreturns.sf config get target-org
The individual keyword/confirmation/prompt values are collected interactively in Stage 3–4 (or accepted from the caller if pre-supplied).
- ——15或18位字符的
{CHANNEL_ID}(前缀为MessagingChannel.Id)。必须已存在且为增强型渠道。0Mj - ——可选;取值为
{CONSENT_TYPE}|ImplicitOptIn|ExplicitOptIn。若未提供,此功能将发起提示。DoubleOptIn - ——可选;关键词记录的
{LANGUAGE}(例如MasterLanguage)。未提供时默认值为en_US。en_US - ——可选;sf CLI的目标组织别名。默认值:
{ORG_ALIAS}返回的结果。sf config get target-org
具体的关键词/确认消息/提示值会在第3-4阶段交互式收集(若调用方预先提供则直接使用)。
Output (to caller)
返回给调用方的结果
Success — no change needed:
json
{"ok": true, "noop": true, "consentType": "ImplicitOptIn|ExplicitOptIn|DoubleOptIn", "languageKeywordIds": ["3Or..."], "message": "Consent already configured and activation-ready"}Success — consent configured:
json
{"ok": true, "consentType": "ExplicitOptIn", "channelFieldsSet": ["ConsentType","OptInPrompt"],
"languageKeywordId": "3Or...", "language": "en_US", "created": true|false, "activationReady": true}Precondition / validation not met:
json
{"ok": false, "kind": "not-enhanced", "hint": "consent fields apply to Enhanced channels only; this channel is PlatformType=<x>"}
{"ok": false, "kind": "missing-consent-input", "hint": "<which required keyword/prompt for the chosen ConsentType is missing>"}Failure:
json
{"ok": false, "kind": "channel-patch-failed", "message": "..."}
{"ok": false, "kind": "keyword-record-failed", "message": "..."}
{"ok": false, "kind": "verify-failed", "hint": "writes returned success but a re-read shows the channel is still not consent-ready"}成功——无需修改:
json
{"ok": true, "noop": true, "consentType": "ImplicitOptIn|ExplicitOptIn|DoubleOptIn", "languageKeywordIds": ["3Or..."], "message": "Consent already configured and activation-ready"}成功——同意机制已配置:
json
{"ok": true, "consentType": "ExplicitOptIn", "channelFieldsSet": ["ConsentType","OptInPrompt"],
"languageKeywordId": "3Or...", "language": "en_US", "created": true|false, "activationReady": true}前置条件/校验未通过:
json
{"ok": false, "kind": "not-enhanced", "hint": "consent fields apply to Enhanced channels only; this channel is PlatformType=<x>"}
{"ok": false, "kind": "missing-consent-input", "hint": "<which required keyword/prompt for the chosen ConsentType is missing>"}失败:
json
{"ok": false, "kind": "channel-patch-failed", "message": "..."}
{"ok": false, "kind": "keyword-record-failed", "message": "..."}
{"ok": false, "kind": "verify-failed", "hint": "writes returned success but a re-read shows the channel is still not consent-ready"}Stage 1: Read current consent state
阶段1:读取当前同意状态
Read the channel's consent fields and any existing language-keyword records.
bash
sf data query --target-org '{ORG_ALIAS}' \
--query "SELECT Id, DeveloperName, PlatformType, MessageType, MessagingPlatformKey, ConsentType, OptInPrompt, DoubleOptInPrompt, IsRequireDoubleOptIn FROM MessagingChannel WHERE Id = '{CHANNEL_ID}'" \
--json > /tmp/cc-channel.json
sf data query --target-org '{ORG_ALIAS}' \
--query "SELECT Id, MasterLanguage, OptInKeywords, DoubleOptInKeywords, OptInConfirmation, OptOutKeywords, OptOutConfirmation, HelpKeywords, HelpResponse, CustomKeywords, CustomResponse FROM MsgChannelLanguageKeyword WHERE MessagingChannelId = '{CHANNEL_ID}'" \
--json > /tmp/cc-keywords.jsonIf the channel record is missing — halt with
Error: Channel {CHANNEL_ID} not found — check the id, or run the insertion skill first.If — emit and stop.
PlatformType != 'Enhanced'{ok:false, kind:"not-enhanced", ...}No-op check: if is non-null AND the existing language-keyword records already satisfy the readiness matrix for that ConsentType (see Stage 5), emit the envelope and return. Don't re-prompt or overwrite a channel that is already activation-ready.
ConsentTypenoop:true读取渠道的同意字段及已有的语言关键词记录。
bash
sf data query --target-org '{ORG_ALIAS}' \
--query "SELECT Id, DeveloperName, PlatformType, MessageType, MessagingPlatformKey, ConsentType, OptInPrompt, DoubleOptInPrompt, IsRequireDoubleOptIn FROM MessagingChannel WHERE Id = '{CHANNEL_ID}'" \
--json > /tmp/cc-channel.json
sf data query --target-org '{ORG_ALIAS}' \
--query "SELECT Id, MasterLanguage, OptInKeywords, DoubleOptInKeywords, OptInConfirmation, OptOutKeywords, OptOutConfirmation, HelpKeywords, HelpResponse, CustomKeywords, CustomResponse FROM MsgChannelLanguageKeyword WHERE MessagingChannelId = '{CHANNEL_ID}'" \
--json > /tmp/cc-keywords.json若渠道记录不存在——终止并提示
Error: Channel {CHANNEL_ID} not found — check the id, or run the insertion skill first.若——返回并停止运行。
PlatformType != 'Enhanced'{ok:false, kind:"not-enhanced", ...}**无需操作校验:**若非空,且现有语言关键词记录已满足该ConsentType对应的就绪矩阵要求(见阶段5),则返回的结果包并结束。请勿重新提示或覆盖已准备好激活的渠道。
ConsentTypenoop:trueStage 2: Choose the ConsentType
阶段2:选择ConsentType
If wasn't supplied, prompt (do NOT auto-pick):
{CONSENT_TYPE}text
Channel '{developerName}' ({CHANNEL_ID}) — choose a consent model:
1) ImplicitOptIn — end users are opted in by default; you only handle opt-OUT (STOP) keywords.
2) ExplicitOptIn — end users must send an opt-in keyword before you can message them.
3) DoubleOptIn — explicit opt-in plus a second confirming keyword.
Pick [1-3]:Record . Note the field checks that follow (this is the exact server-side activation-readiness contract — see for the source):
{CONSENT_TYPE}references/gotchas.md| ConsentType | MessagingChannel fields | |
|---|---|---|
| ImplicitOptIn | (none required) | |
| ExplicitOptIn | | above + |
| DoubleOptIn | | above + |
¹ is optional (not required for readiness) on Unified SMS / WhatsApp / RCS channels — detect via on an Enhanced channel (the queryable proxy for the server's ). Still recommend setting it for a good end-user experience.
OptInPromptMessageType IN ('Text','WhatsApp','Rcs')isUnifiedSMSOrWhatsappOrRCS若未提供,则发起提示(请勿自动选择):
{CONSENT_TYPE}text
Channel '{developerName}' ({CHANNEL_ID}) — choose a consent model:
1) ImplicitOptIn — end users are opted in by default; you only handle opt-OUT (STOP) keywords.
2) ExplicitOptIn — end users must send an opt-in keyword before you can message them.
3) DoubleOptIn — explicit opt-in plus a second confirming keyword.
Pick [1-3]:记录。请注意后续的字段检查规则(这与服务器端激活就绪校验的规则完全一致——规则来源见):
{CONSENT_TYPE}references/gotchas.md| ConsentType | MessagingChannel字段要求 | |
|---|---|---|
| ImplicitOptIn | 无必填字段 | |
| ExplicitOptIn | | 上述要求 + |
| DoubleOptIn | | 上述要求 + |
¹ 在Unified SMS/WhatsApp/RCS渠道中,为可选(就绪校验不要求)——可通过增强型渠道的来判断(这是服务器端的可查询代理)。但为了良好的用户体验,仍建议设置该字段。
OptInPromptMessageType IN ('Text','WhatsApp','Rcs')isUnifiedSMSOrWhatsappOrRCSStage 3: Collect channel-level prompt values
阶段3:收集渠道级提示值
Only prompt for the fields the chosen ConsentType requires (see the matrix above). Skip this stage entirely for — it needs no channel-level prompt fields.
ImplicitOptInFor / :
ExplicitOptInDoubleOptIntext
Opt-in prompt (sent when a reply doesn't match an opt-in keyword):For , also:
DoubleOptIntext
Double-opt-in prompt (sent when a reply doesn't match a double-opt-in keyword):Trim whitespace. If a required prompt is empty after trimming, re-prompt once; on a second empty, emit .
{ok:false, kind:"missing-consent-input", hint:"..."}仅提示所选ConsentType要求的字段(见上述矩阵)。对于类型,可完全跳过此阶段——它不需要任何渠道级提示字段。
ImplicitOptIn对于/类型:
ExplicitOptInDoubleOptIntext
Opt-in prompt (sent when a reply doesn't match an opt-in keyword):对于类型,还需提示:
DoubleOptIntext
Double-opt-in prompt (sent when a reply doesn't match a double-opt-in keyword):去除首尾空格。若必填提示去除空格后为空,重新提示一次;若第二次仍为空,返回。
{ok:false, kind:"missing-consent-input", hint:"..."}Stage 4: Configure the per-language keyword record
阶段4:配置按语言划分的关键词记录
Collect the keyword lists and confirmation replies for (default ), then create or update the record.
{LANGUAGE}en_USMsgChannelLanguageKeywordLoad and follow it — it holds the full field list, the comma-separated-keyword semantics, the create-vs-update decision (reuse an existing record for the same language rather than duplicating), and the Unified-SMS help/custom-keyword rules.
references/language-keywords.mdThe minimum per ConsentType (again, from the readiness contract):
- ImplicitOptIn: (e.g.
OptOutKeywords) +STOP,UNSUBSCRIBE.OptOutConfirmation - ExplicitOptIn: the above + (e.g.
OptInKeywords).START,YES - DoubleOptIn: the above + (e.g.
DoubleOptInKeywords).CONFIRM
OptInConfirmationHelpKeywordsHelpResponseCustomKeywordsCustomResponse收集(默认)对应的关键词列表及确认回复,然后创建或更新记录。
{LANGUAGE}en_USMsgChannelLanguageKeyword请加载并遵循中的规则——其中包含完整字段列表、逗号分隔关键词的语义、创建/更新决策逻辑(复用同语言的现有记录而非重复创建),以及Unified SMS帮助/自定义关键词规则。
references/language-keywords.md各ConsentType的最低要求(同样来自就绪校验规则):
- ImplicitOptIn:(例如
OptOutKeywords) +STOP,UNSUBSCRIBE。OptOutConfirmation - ExplicitOptIn:上述要求 + (例如
OptInKeywords)。START,YES - DoubleOptIn:上述要求 + (例如
DoubleOptInKeywords)。CONFIRM
OptInConfirmationHelpKeywordsHelpResponseCustomKeywordsCustomResponseStage 5: Write channel fields + keyword record
阶段5:写入渠道字段 + 关键词记录
Write the channel-level fields in one PATCH (only the fields the ConsentType requires).
Quoting rule (load-bearing): splits on spaces, so any value containing a space must be wrapped in single quotes inside the double-quoted string — e.g. . An unquoted fails with (verified live on sdb6c). Prompts almost always contain spaces, so always quote them.
sf data update record --values--valuesOptInPrompt='Reply YES to receive messages'OptInPrompt=Reply YES ...Malformed key=value pairbash
undefined通过一次PATCH操作写入渠道级字段(仅写入所选ConsentType要求的字段)。
引号规则(关键):会按空格拆分内容,因此任何包含空格的值必须在双引号包裹的字符串内再用单引号包裹——例如。未加单引号的会因报错(已在sdb6c环境验证)。提示消息几乎都包含空格,因此务必添加单引号。
sf data update record --values--valuesOptInPrompt='Reply YES to receive messages'OptInPrompt=Reply YES ...Malformed key=value pairbash
undefinedImplicitOptIn — ConsentType only
ImplicitOptIn — 仅设置ConsentType
sf data update record --target-org '{ORG_ALIAS}' --sobject MessagingChannel
--record-id '{CHANNEL_ID}' --values "ConsentType=ImplicitOptIn" --json > /tmp/cc-patch.json
--record-id '{CHANNEL_ID}' --values "ConsentType=ImplicitOptIn" --json > /tmp/cc-patch.json
sf data update record --target-org '{ORG_ALIAS}' --sobject MessagingChannel
--record-id '{CHANNEL_ID}' --values "ConsentType=ImplicitOptIn" --json > /tmp/cc-patch.json
--record-id '{CHANNEL_ID}' --values "ConsentType=ImplicitOptIn" --json > /tmp/cc-patch.json
ExplicitOptIn
ExplicitOptIn
sf data update record --target-org '{ORG_ALIAS}' --sobject MessagingChannel
--record-id '{CHANNEL_ID}' --values "ConsentType=ExplicitOptIn OptInPrompt='{OPT_IN_PROMPT}'" --json > /tmp/cc-patch.json
--record-id '{CHANNEL_ID}' --values "ConsentType=ExplicitOptIn OptInPrompt='{OPT_IN_PROMPT}'" --json > /tmp/cc-patch.json
sf data update record --target-org '{ORG_ALIAS}' --sobject MessagingChannel
--record-id '{CHANNEL_ID}' --values "ConsentType=ExplicitOptIn OptInPrompt='{OPT_IN_PROMPT}'" --json > /tmp/cc-patch.json
--record-id '{CHANNEL_ID}' --values "ConsentType=ExplicitOptIn OptInPrompt='{OPT_IN_PROMPT}'" --json > /tmp/cc-patch.json
DoubleOptIn
DoubleOptIn
sf data update record --target-org '{ORG_ALIAS}' --sobject MessagingChannel
--record-id '{CHANNEL_ID}'
--values "ConsentType=DoubleOptIn OptInPrompt='{OPT_IN_PROMPT}' DoubleOptInPrompt='{DBL_PROMPT}' IsRequireDoubleOptIn=true" --json > /tmp/cc-patch.json
--record-id '{CHANNEL_ID}'
--values "ConsentType=DoubleOptIn OptInPrompt='{OPT_IN_PROMPT}' DoubleOptInPrompt='{DBL_PROMPT}' IsRequireDoubleOptIn=true" --json > /tmp/cc-patch.json
If `status !== 0`: emit `{ok:false, kind:"channel-patch-failed", message: ...}` and return.
Then create or update the `MsgChannelLanguageKeyword` record per `references/language-keywords.md`. If it fails: `{ok:false, kind:"keyword-record-failed", message: ...}`.
---sf data update record --target-org '{ORG_ALIAS}' --sobject MessagingChannel
--record-id '{CHANNEL_ID}'
--values "ConsentType=DoubleOptIn OptInPrompt='{OPT_IN_PROMPT}' DoubleOptInPrompt='{DBL_PROMPT}' IsRequireDoubleOptIn=true" --json > /tmp/cc-patch.json
--record-id '{CHANNEL_ID}'
--values "ConsentType=DoubleOptIn OptInPrompt='{OPT_IN_PROMPT}' DoubleOptInPrompt='{DBL_PROMPT}' IsRequireDoubleOptIn=true" --json > /tmp/cc-patch.json
若`status !== 0`:返回`{ok:false, kind:"channel-patch-failed", message: ...}`并结束。
然后根据`references/language-keywords.md`创建或更新`MsgChannelLanguageKeyword`记录。若操作失败:返回`{ok:false, kind:"keyword-record-failed", message: ...}`。
---Stage 6: Verify activation readiness
阶段6:验证激活就绪状态
Re-read both the channel and its keyword records (same two queries as Stage 1). Confirm, per the chosen ConsentType's row in the Stage 2 matrix, that every required field is now non-null on the channel AND on at least one keyword record for the configured language.
If any required field is still null: emit .
{ok:false, kind:"verify-failed", hint:"<which requirement is unmet>"}Otherwise emit the success envelope with .
activationReady: true重新读取渠道及其关键词记录(使用与阶段1相同的两个查询)。根据阶段2矩阵中所选ConsentType对应的行,确认渠道上的所有必填字段均已非空,且至少一条对应语言的关键词记录上的所有必填字段也已非空。
若任何必填字段仍为空:返回。
{ok:false, kind:"verify-failed", hint:"<which requirement is unmet>"}否则返回包含的成功结果包。
activationReady: trueStage 7: Report to caller
阶段7:向调用方报告结果
Report the JSON envelope. If this skill is the leaf (user invoked it directly), render:
Success — Consent configured — channel {CHANNEL_ID} is now {CONSENT_TYPE} with a {LANGUAGE} keyword record. Activation-ready.- (no-op path)
Info: Consent already configured — {CONSENT_TYPE}, {N} language record(s). No changes. - (not-enhanced)
Warning: This channel is PlatformType={x}, not Enhanced — consent fields don't apply here. - (missing-consent-input)
Warning: Missing required consent input for {CONSENT_TYPE}: {what}. Re-run and provide it. - (other failures)
Error: {kind}: {message}
返回JSON结果包。若此功能为直接被用户调用的终端功能,则显示:
Success — Consent configured — channel {CHANNEL_ID} is now {CONSENT_TYPE} with a {LANGUAGE} keyword record. Activation-ready.- (无需操作场景)
Info: Consent already configured — {CONSENT_TYPE}, {N} language record(s). No changes. - (非增强型渠道场景)
Warning: This channel is PlatformType={x}, not Enhanced — consent fields don't apply here. - (缺少必填输入场景)
Warning: Missing required consent input for {CONSENT_TYPE}: {what}. Re-run and provide it. - (其他失败场景)
Error: {kind}: {message}
Worked examples
运行示例
For reference runs of the ImplicitOptIn (opt-out only), ExplicitOptIn, and DoubleOptIn paths, see .
references/worked-examples.md如需参考ImplicitOptIn(仅选择退出)、ExplicitOptIn和DoubleOptIn流程的运行示例,请查看。
references/worked-examples.mdGotchas
注意事项
Known gotchas — the exact per-ConsentType activation-readiness contract (and its source), comma-separated keyword storage, the "ImplicitOptIn still needs a keyword record" trap, one-record-per-language uniqueness, the Unified-SMS help/French-custom rules, and the OptInPrompt Unified-SMS/WhatsApp/RCS exemption.
When troubleshooting an unexpected result, or before modifying this skill, load and follow it.
references/gotchas.md已知注意事项——各ConsentType对应的激活就绪校验规则(及其来源)、逗号分隔关键词的存储方式、“ImplicitOptIn仍需关键词记录”的陷阱、每种语言仅一条记录的唯一性要求、Unified SMS帮助/法语自定义规则,以及OptInPrompt在Unified SMS/WhatsApp/RCS渠道中的豁免规则。
排查异常结果或修改此功能前,请加载并遵循中的内容。
references/gotchas.md