This topic describes the features and usage of the WebOffice Document AI Assistant plug-in.
The Document AI Assistant is an intelligent document creation tool powered by Tongyi, a large language model from Alibaba. This assistant helps you efficiently edit, polish, and translate documents to significantly improve your document processing efficiency and quality.
Features
Feature category | Description |
Continue writing | Intelligently continues writing from the selected text to provide ideas and inspiration for content creation. |
Generate summary | Generates a summary of the selected text to quickly extract key points and understand the main idea. |
Translate | Supports translation into 12 languages to meet cross-lingual document processing needs. |
Polish text | Improves text quality and readability by optimizing grammar, spelling, word choice, sentence structure, and overall style. |
Enrich content | Expands on the selected content using AI to add richness and depth. |
Rewrite tone | Rewrites the selected content in a different tone. You can choose from professional, casual, direct, confident, or friendly. |
Limits
This feature is currently available only on WebOffice for PC. It is not supported on mobile H5 pages or in miniapps.
Developer integration
1. Server-side API encapsulation
The Document AI Assistant calls the x-oss-process API operation of Object Storage Service (OSS). Before you call this API operation, you must bind an IMM project to an OSS bucket.

After the binding is complete, go to the Document Mind tab to request a quota:

Encapsulate an API operation on your server to obtain signed URLs for the Document AI API operations, such as /file/get_ai_process_url.
The following code provides an example of the main server-side logic:
import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.*;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.model.GeneratePresignedUrlRequest;
import java.net.URL;
import java.util.Date;
public class Demo {
public static void main(String[] args) throws Throwable {
// The China (Hangzhou) endpoint is used as an example. Specify the endpoint of your region.
String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
// Specify the region ID that corresponds to the endpoint, for example, cn-hangzhou.
String region = "cn-hangzhou";
// We strongly recommend that you do not save your access credentials in your project code. Otherwise, your access credentials may be leaked, which poses a threat to the security of all resources in your account. This example shows how to obtain access credentials from environment variables. Before you run this example, configure the environment variables.
EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
// Specify the bucket name, for example, examplebucket.
String bucketName = "examplebucket";
// Specify the full path of the object. The full path cannot contain the bucket name.
String objectName = "exampledir/exampleobject.docx";
// Create an OSSClient instance.
// When the OSSClient instance is no longer used, call the shutdown method to release resources.
ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
// Explicitly declare the use of the V4 signature algorithm.
clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
OSS ossClient = OSSClientBuilder.create()
.endpoint(endpoint)
.credentialsProvider(credentialsProvider)
.clientConfiguration(clientBuilderConfiguration)
.region(region)
.build();
try {
// Set the expiration time of the signed URL to 10 minutes.
Date expiration = new Date(new Date().getTime() + 1000 * 60 * 10 );
GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(bucketName, objectName, HttpMethod.POST);
req.setExpiration(expiration);
req.setContentType("text/plain; charset=UTF-8");
// Note: Pass an empty string for Process.
// Add sub-resource parameters.
req.addQueryParameter("x-oss-process", null);
URL signedUrl = ossClient.generatePresignedUrl(req);
System.out.println(signedUrl);
} catch (OSSException oe) {
System.out.println("Caught an OSSException, which means your request made it to OSS, "
+ "but was rejected with an error response for some reason.");
System.out.println("Error Message:" + oe.getErrorMessage());
System.out.println("Error Code:" + oe.getErrorCode());
System.out.println("Request ID:" + oe.getRequestId());
System.out.println("Host ID:" + oe.getHostId());
} catch (ClientException ce) {
System.out.println("Caught an ClientException, which means the client encountered "
+ "a serious internal problem while trying to communicate with OSS, "
+ "such as not being able to access the network.");
System.out.println("Error Message:" + ce.getMessage());
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}
}
}# -*- coding: utf-8 -*-
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider
# Obtain access credentials from environment variables. Before you run this example, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
auth = oss2.ProviderAuth(EnvironmentVariableCredentialsProvider())
# Set yourEndpoint to the endpoint of the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com.
# Specify the bucket name, for example, examplebucket.
bucket = oss2.Bucket(auth, 'https://oss-cn-hangzhou.aliyuncs.com', 'examplebucket')
# Specify the full path of the document for which you want to request a preview. The full path cannot contain the bucket name.
key = 'example.docx'
# Generate a signed URL and set the expiration time to 10 minutes. The expiration time is in seconds.
# Note: Pass an empty string for x-oss-process.
url = bucket.sign_url('POST', key, 10 * 60, headers={'Content-Type': 'text/plain; charset=UTF-8'}, params={'x-oss-process': ''})
print(url)package main
import (
"fmt"
"os"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
)
func main() {
// Obtain access credentials from environment variables. Before you run this example, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
provider, err := oss.NewEnvironmentVariableCredentialsProvider()
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// Create an OSSClient instance.
// Set yourEndpoint to the endpoint of the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com. Specify the endpoint of your region.
client, err := oss.New("yourEndpoint", "", "", oss.SetCredentialsProvider(&provider))
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// Specify the name of the bucket where the file is located, for example, examplebucket.
bucketName := "examplebucket"
bucket, err := client.Bucket(bucketName)
if err != nil {
fmt.Println("Error:", err); os.Exit(-1)
}
// Specify the full path of the document for which you want to request a preview. The full path cannot contain the bucket name.
ossObjectName := "exampledir/exampleobject.docx"
// Set the style that contains the document preview parameters.
// Generate a signed URL and set the expiration time to 600s.
// Note: Pass an empty string for Process.
signedURL, err := bucket.SignURL(ossObjectName, oss.HTTPPost, 600, oss.ContentType("text/plain; charset=UTF-8"), oss.Process(""))
if err != nil {
fmt.Println("Error:", err); os.Exit(-1)
} else {
fmt.Println(signedURL)
}
}const OSS = require('ali-oss');
const client = new OSS({
// Set yourregion to the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to oss-cn-hangzhou.
region: 'yourregion',
// Obtain access credentials from environment variables. Before you run this example, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
accessKeyId: process.env.OSS_ACCESS_KEY_ID,
accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET,
// Set yourbucketname to the bucket name.
bucket: 'yourbucketname'
});
// Set the style that contains the document preview parameters.
// Generate a signed URL and set the expiration time to 10 minutes.
const signUrl = clientsignatureUrl(objectKey, {
method: 'POST',
subResource: {
'x-oss-process': '', // Note: Pass an empty string here.
},
expires: 60*10, // Unit: seconds.
'Content-Type': 'text/plain; charset=UTF-8',
});
console.log("signUrl="+signUrl);A signature is required for the following API operations:
2. Use the JS-Plugins on the frontend
After you integrate the JS-SDK for document editing, import the following script:
<!-- Import the JS SDK -->
<script src="https://g.alicdn.com/IMM/office-js/1.1.19/aliyun-web-office-sdk.min.js"></script>
<!-- Import the plugin SDK -->
<script src="https://g.alicdn.com/IMM/office-js-plugins/1.3.0/aliyun-web-office-plugins.min.js"><script>In the example, 1.1.19 is the JS-SDK version number. Replace it with the actual version number. For more information about the latest version, see JS-SDK versions.
In the example, 1.3.0 is the JS-Plugins version number. Replace it with the actual version number. For more information about the latest version, see JS-SDK plug-in versions.
Initialize the plug-in
After you call the aliyun.config method to initialize the JS-SDK, call the aliyun.initAIPlugin method to initialize the Document AI Assistant plug-in.
let ins = aliyun.config({
....
})
// Call aliyun.initAIPlugin after the instance is ready.
await ins.ready();
// Use the AI plug-in.
aliyun.initAIPlugin({
sdkInstance: ins, // Pass the SDK instance.
// aiHelperLink: 'https://www.alibabacloud.com/help/xxxx', // The link to the AI assistant help document on the panel.
async onGetAIProcessUrl({ content_type, content_md5 }){
/** The following logic obtains the x-oss-process URL. You must call the encapsulated server-side API operation. */
let opt = {
content_type,
// content_md5,
file_name: "test-object.docx",
};
let { ai_process_url } = await $.post("/file/get_ai_process_url", opt);
return {
ai_process_url, // Required.
// content_md5, // Optional. If this parameter is not passed, the content_md5 item is not signed.
};
},
async onFeedback(info){
// Record.
}
})2.1. initAIPlugin parameters
Field | Type | Required | Description |
sdkInstance | Object | Yes | The SDK instance. This is the return value of |
onGetAIProcessUrl | ({content_type: string, content_md5:string })=>Promise<{ai_process_url:string,content_md5?:string}> | Yes | The method to obtain the signed URL for `x-oss-process`. |
aiHelperLink | string | No | The link to the AI assistant help document on the panel. |
onFeedback | (info:FeedbackInfo)=>void | No | The FeedbackInfo parameter. |
2.2. FeedbackInfo fields
Field | Type | Description |
type | string | Valid values: 'thumb-up', 'thumb-down' |
data | object | The specific feedback information. |
User guide
In the Word editor, click Document AI Assistant on the right side of the Start toolbar, or press the keyboard shortcut (Alt + / on Windows, Control + / on macOS). This opens the Document AI Assistant menu, allowing you to optimize the selected text or the text at the cursor position.
