TikTok: allow a comments-only connection (EEA accounts can't get Business Messaging scopes)
TikTok's Business Messaging API is not available to accounts registered in the EEA, Switzerland or the UK, so these accounts can't be granted message.list.read/send/manage. ChatbotX treats those scopes as core: the connect is refused without them, and saving TikTok credentials fails if the DIRECT_MESSAGE webhook subscription is rejected.
As a result, EU accounts can't use TikTok Comment Automation (public reply, like, hide) at all, even though it only needs the comment scopes.
Proposal: an opt-in env var TIKTOK_COMMENTS_ONLY=true. When set:
- the messaging scopes are not requested or required;
comment.listandcomment.list.manageare required instead - only the
COMMENTwebhook is subscribed, and its failure fails the save
Default behaviour is unchanged. I'll open a PR with tests.
Thanks a lot @rancaHoratiu, both for the clear write-up and for opening #1564 with tests. You're right about the root cause: we treat the Business Messaging scopes as core, so EEA, Swiss and UK accounts can't connect at all, even though comment automation only needs the comment scopes.
We'd like to solve it a bit differently, so we're going to open our own PR rather than merge #1564. Here's why:
- Per credential instead of one switch for the whole server. TikTok app credentials are stored per platform and per reseller tenant. One
TIKTOK_COMMENTS_ONLYflag would put every customer on the server into the same mode, so EU and non-EU accounts couldn't be served side by side. Instead, the TikTok settings dialog will get two switches, Messaging and Comments, saved with the credential. At least one has to stay on, and the default is unchanged. - Both connect paths. There are two places that check the granted scopes:
exchangeCodeinintegration.tsand the oldercallbackHandlerinhandlers/callback.ts. #1564 changes only the first, so a connect through the second path would still be refused. Both will use one shared helper. - Clear errors for features that need messaging. A comment-to-message private reply, or turning on Comment-to-Message on a comments-only connection, will stop early with a clear error instead of returning a confusing TikTok API error.
- Docs in
docs/comment-automation.mdcovering what works and what doesn't for EEA, Swiss and UK accounts.
We'll link the new PR here and close #1564 in favour of it, credited to your proposal. Since you have an EEA account at hand, it would be a great help if you could test the PR once it's up. Thanks again!
Thanks @sung17! The per-credential approach makes a lot more sense, and good catch on callbackHandler.
Happy to test the PR on our EEA account. One heads-up: we're only now applying for TikTok's Accounts API access (comment scopes only), so live testing may take a few weeks until the app is approved. I'll report back here once it is.
Follow-up PR is up: #1572. It adds the Messaging / Comments switches on the TikTok app credential described above.