> 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).

# Actions

{% hint style="info" %}
:no\_entry: 此插件已弃用，不再受支持。

\
如果你仍在运行旧版插件，我们建议切换到新的 Convai Web SDK： [链接](https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-web-sdk)

\
仅供历史参考——这些文档已不再维护。
{% endhint %}

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

1. 登录到 [Convai 的网站](https://convai.com/) 并进入您的角色详情。
2. 导航到 Actions，启用 Action Generation，并选择您希望 NPC 执行的动作。
3. 回到您的代码中，初始化一个 actionText 状态，用于存储您希望 NPC 执行的动作。

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

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

```javascript
useEffect(()=>{

------------------------------------------------------------------------
//首先在这里初始化 Convai Client。请参考入门页面
//在初始化客户端后调用 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
