tencent cloud

文档Chat시나리오 솔루션WhatsApp Channel-style Official Account Integration Solution

WhatsApp Channel-style Official Account Integration Solution

PDF
聚焦模式
字号
最后更新时间: 2026-04-21 15:19:56

Overview

To meet the growing demand for diverse content creation, efficient subscriber management, and ongoing interaction—and to address the limitations of traditional instant messaging in content management and business service expansion—the Official Account feature has been introduced.
Official Account delivers core capabilities modeled after WeChat Official Accounts, empowering businesses to create and manage dedicated accounts, publish rich media posts, and communicate directly with their subscribers at scale.

Feature Overview

Account owners can publish posts to subscribers and browse previously published posts. Users who subscribe to an Official Account automatically receive new updates and can interact with the account via direct messaging.

Applicable Scenarios

Real-time Information Broadcast
Brand Promotion
Providing Convenient Services
Local Guides
Official Accounts provide a trusted platform for broadcasting information, enabling organizations to quickly share news, updates, and knowledge with a broad audience using rich media formats.
Businesses leverage Official Accounts to deliver brand stories, product announcements, and targeted content directly to users, strengthening brand recognition and influence.
Official Accounts support high-frequency service features, such as online transactions (including transfers and appointment bookings) and information lookups (such as logistics tracking and grade inquiries), offering convenient self-service capabilities for subscribers.
Official Accounts serve as practical guides for local communities by aggregating relevant information—such as locations of community vaccination sites—through rich media, enhancing day-to-day convenience for subscribers.














Business Mode: WeChat-Style

If you need to integrate with multiple external vendors—such as KFC, McDonald's, and others—refer to the interaction examples and technical implementation solutions below. For specific interactions, you must design the UI on top of core IM capabilities.

1. Sample Flows

In a WeChat Official Account-style architecture, business accounts and user accounts are managed separately. Businesses can create and administer Official Accounts from within their business account; however, business accounts cannot function as user accounts. This model is ideal for scenarios where the business and user sides are implemented as two distinct apps, or for clients who want to support switching between business and user modes within a single app. You can use the following interaction examples as a reference when designing your own web or app interfaces.

1.1 Business Web Interaction Example

Create, Edit and Delete Official Channel.



Create Post.



Post, Message Interaction.




1.2 Business App Interaction Example





1.3 User Interaction Example

Subscribers can follow public accounts directly within the app, receive updates from those accounts, and engage through C2C Messages.




2. Implementation Solution

2.1 Feature Overview

An official channel can send broadcast messages to subscribed users and also engage in one-on-one chats with them.
When messages are exchanged, a one-on-one conversation is generated, with the conversationID structured as c2c_officialAccountID.
For management features such as creating an official channel, refer to the server APIs. The IMSDK primarily provides functionalities such as subscribing to an official channel, unsubscribing from an official channel, and retrieving the list of official channels.
Note:
This feature is supported only by the Enhanced edition on v7.6.5011 or later.

2.2 Official Account Profile Fields

Attribute
Definition
Description
officialAccountID
official channel ID
The official channel ID must be prefixed with @TOA#_, can be customized, and has a maximum length of ​48 bytes.
officialAccountName
official channel name
Maximum Length: 150 bytes (UTF-8 encoded, where 1 Chinese character occupies 3 bytes)
faceUrl
Profile photo of the official channel
Maximum Length: 500 bytes
organization
organization name
Maximum Length: 500 bytes (UTF-8 encoded, where 1 Chinese character occupies 3 bytes)
introduction
Introduction of the official channel
Maximum Length: 400 bytes (UTF-8 encoded, where 1 Chinese character occupies 3 bytes)
customData
custom data
Maximum Length: 3000 bytes
createTime
Creation time of the official channel
Unit: Seconds
subscriberCount
The number of subscribed users
The number of active subscribers to the official channel
subscribeTime
The time when the logged-in user subscribed
Unit: Seconds

2.3 Subscribe to an Official channel

To subscribe to an official channel, call the subscribeOfficialAccount method (Java / Swift / Objective-C / C++) and pass the officialAccountID as the parameter.
1. Upon successful subscription, subscribers will receive the onOfficialAccountSubscribed callback notification (Java / Swift / Objective-C / C++) .
2. When the subscribed official channel's profile is modified via server API, subscribers will receive the onOfficialAccountInfoChanged callback notification (Java / Swift / Objective-C / C++) .
3. When the subscribed official channel is deleted via server API, subscribers will receive the onOfficialAccountDeleted callback notification (Java / Swift / Objective-C / C++).
Sample code:
Java
Swift
Objective-C
C++
V2TIMManager.getFriendshipManager().subscribeOfficialAccount("official_test", new V2TIMCallback() {
@Override
public void onSuccess() {
}

@Override
public void onError(int code, String desc) {
}
});

V2TIMManager.getFriendshipManager().addFriendListener(new V2TIMFriendshipListener() {
@Override
public void onOfficialAccountSubscribed(V2TIMOfficialAccountInfo officialAccountInfo) {
}

@Override
public void onOfficialAccountDeleted(String officialAccountID) {
}

@Override
public void onOfficialAccountInfoChanged(V2TIMOfficialAccountInfo officialAccountInfo) {
}
});
V2TIMManager.shared.subscribeOfficialAccount(officialAccountID: "officialAccountID") {
print("subscribeOfficialAccount succ")
} fail: { code, desc in
print("subscribeOfficialAccount fail, \\(code), \\(desc)")
}
V2TIMManager.shared.addFriendListener(listener: self)

func onOfficialAccountSubscribed(officialAccountInfo: V2TIMOfficialAccountInfo) {
print("officialAccountInfo:\\(officialAccountInfo.description)");
}

func onOfficialAccountDeleted(officialAccountID: String) {
print("officialAccountID:\\(officialAccountID)");
}

func onOfficialAccountInfoChanged(officialAccountInfo: V2TIMOfficialAccountInfo) {
print("officialAccountInfo:\\(officialAccountInfo.description)");
}
[[V2TIMManager sharedInstance] subscribeOfficialAccount:@"official_test" succ:^ {
NSLog(@"success");
} fail:^(int code, NSString *desc) {
NSLog(@"fail, code: %d, desc: %@", code, desc);
}];

[[V2TIMManager sharedInstance] addFriendListener:self];

- (void)onOfficialAccountSubscribed:(V2TIMOfficialAccountInfo *)officialAccountInfo {
}

- (void)onOfficialAccountDeleted:(NSString *)officialAccountID {
}

- (void)onOfficialAccountInfoChanged:(V2TIMOfficialAccountInfo *)officialAccountInfo {
}desc
class Callback final : public V2TIMCallback {
public:
using SuccessCallback = std::function<void()>;
using ErrorCallback = std::function<void(int, const V2TIMString&)>;

Callback() = default;
~Callback() override = default;

void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
success_callback_ = std::move(success_callback);
error_callback_ = std::move(error_callback);
}

void OnSuccess() override {
if (success_callback_) {
success_callback_();
}
}
void OnError(int error_code, const V2TIMString& error_message) override {
if (error_callback_) {
error_callback_(error_code, error_message);
}
}

private:
SuccessCallback success_callback_;
ErrorCallback error_callback_;
};

auto callback = new Callback;
callback->SetCallback(
[=]() {
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
delete callback;
});
V2TIMManager::GetInstance()->GetFriendshipManager()->SubscribeOfficialAccount(
"official_test", callback);

class FriendshipListener final : public V2TIMFriendshipListener {
public:
FriendshipListener() = default;
~FriendshipListener() override = default;
void OnOfficialAccountSubscribed(const V2TIMOfficialAccountInfo &info) override {
}
void OnOfficialAccountDeleted(const V2TIMString &officialAccountID) override {
}
void OnOfficialAccountInfoChanged(const V2TIMOfficialAccountInfo &info) override {
}
};

FriendshipListener friendshipListener;
V2TIMManager::GetInstance()->AddFriendshipListener(&friendshipListener);

2.4 Unsubscribe from an Official channel

To unsubscribe from an official channel, call the unsubscribeOfficialAccount method (Java / Swift / Objective-C / C++) and pass the officialAccountID as the parameter.
After successful unsubscription, the user will receive an onOfficialAccountUnsubscribed callback notification(Java / Swift / Objective-C / C++).
Sample code:
Java
Swift
Objective-C
C++
V2TIMManager.getFriendshipManager().unsubscribeOfficialAccount("official_test", new V2TIMCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(int code, String desc) {
}
});

V2TIMManager.getFriendshipManager().addFriendListener(new V2TIMFriendshipListener() {
@Override
public void onOfficialAccountUnsubscribed(String officialAccountID) {
}
});
V2TIMManager.shared.unsubscribeOfficialAccount(officialAccountID: "officialAccountID") {
print("unsubscribeOfficialAccount succ")
} fail: { code, desc in
print("unsubscribeOfficialAccount fail, \\(code), \\(desc)")
}

V2TIMManager.shared.addFriendListener(listener: self)

func onOfficialAccountUnsubscribed(officialAccountID: String) {
print("officialAccountID:\\(officialAccountID)");
}
[[V2TIMManager sharedInstance] unsubscribeOfficialAccount:@"official_test" succ:^ {
NSLog(@"success");
} fail:^(int code, NSString *desc) {
NSLog(@"fail, code: %d, desc: %@", code, desc);
}];

[[V2TIMManager sharedInstance] addFriendListener:self];

- (void)onOfficialAccountUnsubscribed:(V2TIMOfficialAccountInfo *)officialAccountInfo {
}
class Callback final : public V2TIMCallback {
public:
using SuccessCallback = std::function<void()>;
using ErrorCallback = std::function<void(int, const V2TIMString&)>;

Callback() = default;
~Callback() override = default;

void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
success_callback_ = std::move(success_callback);
error_callback_ = std::move(error_callback);
}

void OnSuccess() override {
if (success_callback_) {
success_callback_();
}
}
void OnError(int error_code, const V2TIMString& error_message) override {
if (error_callback_) {
error_callback_(error_code, error_message);
}
}

private:
SuccessCallback success_callback_;
ErrorCallback error_callback_;
};

auto callback = new Callback;
callback->SetCallback(
[=]() {
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
delete callback;
});
V2TIMManager::GetInstance()->GetFriendshipManager()->UnsubscribeOfficialAccount(
"official_test", callback);

class FriendshipListener final : public V2TIMFriendshipListener {
public:
FriendshipListener() = default;
~FriendshipListener() override = default;

void OnOfficialAccountUnsubscribed(const V2TIMString &officialAccountID) override {
}
};

FriendshipListener friendshipListener;
V2TIMManager::GetInstance()->AddFriendshipListener(&friendshipListener);

2.5 Get Official channel List

Call the getOfficialAccountsInfo interface (Java / Swift / Objective-C / C++) to retrieve the official channel list.
When the officialAccountIDList is empty, it returns the list of subscribed official channels.
When specific official channel IDs are provided in officialAccountIDList, it returns information for those specified official channels.
Sample code:
Java
Swift
Objective-C
C++
List<String> officialAccountIDList = new ArrayList<>();
V2TIMManager.getFriendshipManager().getOfficialAccountsInfo(officialAccountIDList, new V2TIMValueCallback<List<V2TIMOfficialAccountInfoResult>>() {
@Override
public void onSuccess(List<V2TIMOfficialAccountInfoResult> v2TIMOfficialAccountInfoResults) {
}

@Override
public void onError(int code, String desc) {
}
});
V2TIMManager.shared.getOfficialAccountsInfo(officialAccountIDList: ["officialAccountID"]) { officialAccountResultList in
officialAccountResultList.forEach { item in
print(item.description)
}
} fail: { code, desc in
print("getOfficialAccountsInfo fail, \\(code), \\(desc)")
}
[[V2TIMManager sharedInstance] getOfficialAccountsInfo:nil succ:^(NSArray<V2TIMOfficialAccountInfoResult *> *resultList) {
[self appendString:[NSString stringWithFormat:@"success:%@", resultList]];
} fail:^(int code, NSString *desc) {
[self appendString:[NSString stringWithFormat:@"fail, code:%d msg:%@", code, desc]];
}];
template <class T>
class ValueCallback final : public V2TIMValueCallback<T> {
public:
using SuccessCallback = std::function<void(const T &)>;
using ErrorCallback = std::function<void(int, const V2TIMString &)>;


ValueCallback() = default;
~ValueCallback() override = default;


void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
success_callback_ = std::move(success_callback);
error_callback_ = std::move(error_callback);
}


void OnSuccess(const T &value) override {
if (success_callback_) {
success_callback_(value);
}
}
void OnError(int error_code, const V2TIMString &error_message) override {
if (error_callback_) {
error_callback_(error_code, error_message);
}
}


private:
SuccessCallback success_callback_;
ErrorCallback error_callback_;
};


auto callback = new ValueCallback<V2TIMOfficialAccountInfoResultVector>{};
callback->SetCallback(
[=](const V2TIMOfficialAccountInfoResultVector& officialAccountInfoResultList) {
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
delete callback;
});

V2TIMManager::GetInstance()->GetFriendshipManager()->GetOfficialAccountsInfo(
officialAccountIDList, callback);

2.6 Official channel Messaging

Messages in a public account are categorized as follows: Broadcast Messages are sent by the public account to all subscribers, while C2C Messages are exchanged between the public account and an individual subscriber.
2.6.1 Send Broadcast Messages
Method 1:
By calling Broadcast Message to Public Account Users, you can deliver Broadcast Messages to all subscribers who follow the public account.
Method 2:
You can create a post by following these steps.
1. Choose the format for your post. The system supports the following three types:
Text-and-image: Includes post content and image assets
Image: Includes image assets only
Text: Includes post content only
2. Enter your post content in the input field and upload local images in the image upload area.
3. Click Add Link next to the Post Content title to insert hyperlinks in your post for secondary navigation.
4. Content preview is supported. The information you enter will be displayed in real time in the preview area on the right.
5. Publish the post. Once all information is completed on the post creation page, click the Release button to send your post. After successful publication, the post will appear in the post list.



2.6.2 One-to-One Messaging
Subscriber to Official channel:
Use the send a message sendMessage (Java / Swift / Objective-C /C++) with the official channel's officialAccountID as the receiver.
Official channel to Subscriber:
From_Account: Official channel's officialAccountID.
To_Account: Subscriber's userID.
2.6.3 Receive Messages
Both message types can be received via the IM SDK's ​message listener.

2.7 Create an Official Account

Method 1:
To create a public account programmatically, call the Create Public Account API.
Method 2:
On the Public Account Management page, click the Create Public Account button. This will open a dialog where you can enter the account name, description, and upload an avatar. Once all fields are completed, click Create to save the new public account.




Edit and Delete an Official Account

Method 1:
Administrators can update account information by calling the Edit Public Account Info API, or remove an account by calling the Destroy Public Account API.
Method 2:
On the public account management page, click the Edit button to modify a public account. You can update the account's name, description, and avatar.




Business Mode: WhatsApp-Style

If you need to integrate with multiple external vendors—such as KFC, McDonald's, and others—refer to the interaction examples and technical implementation solutions below. For specific interactions, you must design the UI on top of core IM capabilities.

1. Sample Flows

The WhatsApp-style channel implements Official Account messaging on top of group chat. Users join a group to subscribe to an Official Account, and each account supports up to 1 million subscribers. Account owners and administrators can send messages to all subscribers, while regular users can only receive messages and respond with emoji reactions.

You can use conversation groups to separate Official Account conversations from regular C2C and group chats in your app. The default limit is 1,000 Official Accounts per app (bounded by the Conversation Group limit). To increase this limit, contact us.

This mode is well-suited for applications where both business and consumer interfaces are available in the same app or web platform. Use the following interaction examples as a reference when designing your interfaces.

1.1 Business Web Interaction Example

Create and Edit Official Channel.



Post.




1.2 Business App Interaction Example





1.3 User Interaction Example

Subscribers can follow public accounts directly within the app, receive posts from those accounts, and interact by responding with emoji reactions.




2. Implementation Solution

2.1 Create an Official Account

Creating an official account is equivalent to Creating a Group. Set the groupType to Community, which supports 100,000 to 1 million members per group. After creation, Setting a Custom Group Field to mark the Community as an official account and distinguish it from other regular Community group chats.

2.2 Subscribe to an Official Account

Subscribing to an official account is equivalent to Joining a Group.
After joining, if you need to display unread counts for official accounts (specific Communities) separately from regular C2C chat and group chats, use the createConversationGroup API (createConversationGroup), and add official account conversations (specific Communities) to the official account group using addConversationsToGroup.

2.3 Unsubscribe from an Official Account

Unsubscribing from an official account is equivalent to Leaving a Group.

2.4 Retrieve the Official Account List

Call getJoinedGroupList to retrieve the official account list. After obtaining all joined Communities, call getGroupsInfo to check if the custom group field contains the official account marker, allowing you to identify the list of official accounts (Communities) the user has joined.

2.5 Send Messages as the Official Account Owner

The official account owner uses the group chat message sending capability to send text, rich media, custom, and other types of messages.

2.6 User Emoji Reactions

Users can react to specific messages with emoji reactions.

Platform Official Account Mode

If your platform operates its own Official Account and does not need to expose it to external businesses, you can enable this feature directly through the console. The console is accessible to account owners only and supports creating, editing, and managing Official Accounts, as well as viewing and publishing posts.

For client-side integration, follow the WeChat-style Official Account approach described in this document. For step-by-step instructions, see the Implementation Solution under Business Mode: WeChat-Style.





帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈