> 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/other-integrations/discord/hosting-discord-bot-from-replit.md).

# 从 Replit 托管 Discord Bot

成功从 Replit 托管一个连接到 Convai API 的 Discord Bot 服务器

### [Repl 链接](https://replit.com/@Himadri-Sankar2/ConvaiDiscordIntegration?v=1)

以下是从 Replit 成功运行 Discord 机器人服务器的步骤

### 步骤：

1. 注册 [Replit](https://replit.com/)然后访问上面提到的链接，打开已发布的 Repl。
2. 进入页面后，点击 **Fork Repl**.

   在弹出的通知中再次点击 **Fork Repl** 。

   <figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FV1YumpobVXjpbghw9VVB%2Fdbhr-ss-1.png?alt=media&amp;token=aa8bb722-d206-47a4-a22c-675d48ef70d3" alt=""><figcaption></figcaption></figure>
3. 这样会在你的账户中创建一份代码副本。成功创建后，代码会在编辑器中打开。

   <figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FclmZoyy5xSQ4xLKvkin4%2Fdbhr-ss-2.png?alt=media&amp;token=3e8582c3-f022-4afa-af99-575bbbfbcd83" alt=""><figcaption></figcaption></figure>
4. 前往屏幕左下角的 **Secrets** 。

   <figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FqnkbJ5bsgiaM7WLVP7AU%2Fdbhr-ss-3.png?alt=media&amp;token=b3da6429-77b0-4cb4-8b7b-311d62202f83" alt=""><figcaption></figcaption></figure>
5. 现在添加以下凭据。请直接从此处复制密钥，以避免输入错误。

   1. Convai API 密钥详情：

      ```properties
      密钥：CONVAI_API_KEY
      值：<your unique API key from Convai>
      ```
   2. Convai 角色 ID：

      ```properties
      密钥：CONVAI_CHARACTER_ID
      值：<the unique ID of the character that you designed on Convai website>
      ```
   3. 允许的频道：

      ```properties
      密钥：ALLOWED_CHANNELS
      值：<mention the name of the channels separated by ','. Example: 'chat-with-convaibot,interactive-avatars'>
      ```
   4. Discord 机器人详情：

      ```properties
      密钥：DISCORD_BOT_TOKEN
      值：<the token generated while creating the discord bot>
      ```

   注意：ALLOWED\_CHANNELS 会限制机器人仅在列表中指定的频道内响应。此设置会影响已邀请该机器人的所有服务器。若要添加新服务器，需要将新服务器允许的频道加入列表。你可能还需要重新运行 Repl。
6. 输入详细信息后，界面应类似于以下内容

   <figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FBU6cmAtCB45WMIW26Hr8%2Fdbhr-ss-5.png?alt=media&amp;token=54256b61-5b45-43e5-bc55-c1495d838744" alt=""><figcaption></figcaption></figure>
7. 然后点击顶部的 **Run** 按钮启动机器人。看到日志显示机器人已启动后，就全部完成了。


---

# 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/other-integrations/discord/hosting-discord-bot-from-replit.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.
