> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/web-plugins/convai-web-sdk-1/actions.md).

# 动作

对于已弃用的无作用域 Web SDK，请遵循保留的动作工作流；或者迁移到当前 Convai Web SDK 的动作事件和配置界面。

{% hint style="warning" %}
**已于 2026 年 8 月 26 日弃用。** 无作用域的 `convai-web-sdk` 包不再受支持。请迁移到 [当前 Convai Web SDK 中的 Actions](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/web-plugins/convai-web-sdk/actions.md)。此页面仅供历史参考，不再维护。
{% endhint %}

要设置 Actions，请按照以下步骤操作：

1. 登录 [Convai 网站](https://convai.com/) ，然后前往角色详情页。
2. 前往 Actions，启用 Action Generation，然后选择要让 NPC 执行的操作。
3. 返回代码，初始化一个 actionText 状态，用于存储你希望 NPC 执行的操作。

```javascript
const [actionText, setActionText] = useState("");
```

3. 在检查音频响应的同一个 useEffect 中。请参阅 [入门](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/web-plugins/convai-web-sdk-1/getting-started.md) 页面，快速了解如何以及在何处检查音频响应。

```javascript
useEffect(()=>{

------------------------------------------------------------------------
//首先在此处初始化 Convai 客户端。请参阅入门页面
//初始化客户端后调用 setResponseCallback 方法
//需要设置 onAudioPlay 和 onAudioStop 方法
------------------------------------------------------------------------

if (response.hasActionResponse()) {
        let actionResponse = response.getActionResponse();
        let parsedActions = actionResponse.getAction().trim().split("\n");
        setActionText(parsedActions[0].split(", "));
  }
 },[])
```

Actions 已设置完成，现在你可以使用 ActionText 执行所需的操作。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/web-plugins/convai-web-sdk-1/actions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
