# AI use cases for Octop Gateway (TencentCloud/octop-gateway)

Repo: [TencentCloud/octop-gateway](https://github.com/TencentCloud/octop-gateway) | Use cases: 5 | Page: https://dedupedai.com/use-cases/tencentcloud-octop-gateway/

octop-gateway is a Python library that connects AI agents and bots to many instant-messaging platforms through one message abstraction and one processor.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Run a working Telegram echo bot in under an hour: https://dedupedai.com/use-cases/tencentcloud-octop-gateway/telegram-echo-bot-in-minutes/
- Serve one agent on Feishu, DingTalk, and QQ at once: https://dedupedai.com/use-cases/tencentcloud-octop-gateway/one-agent-across-feishu-dingtalk-qq/
- Stream an LLM agent's reply token by token into chat: https://dedupedai.com/use-cases/tencentcloud-octop-gateway/stream-llm-tokens-to-chat/
- Create QQ Bot credentials by scanning a QR code: https://dedupedai.com/use-cases/tencentcloud-octop-gateway/bind-qq-bot-by-qr-code/
- Run two Feishu apps for two teams in one process: https://dedupedai.com/use-cases/tencentcloud-octop-gateway/isolate-two-feishu-teams/

## How to run a working Telegram echo bot in under an hour with Octop Gateway

Repo: [TencentCloud/octop-gateway](https://github.com/TencentCloud/octop-gateway) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Install the library and run the README echo example to confirm messages flow end to end.

**Who it is for:** A developer who wants a first working IM bot before building real agent logic.

**The problem:** Setting up bot transport, parsing, and replies from scratch takes time before any agent logic can be tested.

**The outcome:** A running Telegram bot that replies to each message with an echo, showing the full inbound and outbound path.

### Steps

1. Run `pip install octop-gateway` in a Python 3.12+ environment.
2. Save the minimal echo bot example from the README as a Python file, and set the environment variable TELEGRAM_BOT_TOKEN to your bot token.
3. Run the saved file with `python <your-file>.py`. (inferred, check the README)
4. Send a text message to your Telegram bot and check that it replies with the text prefixed by 'Echo: '.

### Prompt to paste into your agent

```text
Using the octop-gateway repo at TencentCloud/octop-gateway, install the core package and run the Telegram echo example with my bot token stored in TELEGRAM_BOT_TOKEN. Report whether the bot replies 'Echo: <message>' to a test message from <target chat>. Verify that the process stays running after startup.
```

### Caveat

The README gives the Telegram example only; confirm your bot token and Python version before expecting a reply.

Risk, credentials: The Telegram bot token must be kept in an environment variable and never committed to source control.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/tencentcloud-octop-gateway/telegram-echo-bot-in-minutes/

## How to serve one agent on Feishu, DingTalk, and QQ at once with Octop Gateway

Repo: [TencentCloud/octop-gateway](https://github.com/TencentCloud/octop-gateway) | Difficulty: Intermediate | Time: 1 hour | Basis: From the README

Attach three IM platforms to one processor so the agent logic is written once.

**Who it is for:** A team lead whose users are split across Feishu, DingTalk, and QQ and who wants one bot behavior everywhere.

**The problem:** Writing separate handlers for each IM platform duplicates agent logic and multiplies maintenance work.

**The outcome:** One async processor that answers messages from three platforms, with the source shown in the reply.

### Steps

1. Run `pip install "octop-gateway[examples]"` to install the library with the example extras.
2. Copy `.env.example` to `.env` and fill in FEISHU_APP_ID, FEISHU_APP_SECRET, QQ_APP_ID, QQ_TOKEN, QQ_SECRET, DINGTALK_APP_KEY, and DINGTALK_APP_SECRET.
3. Write one async processor that yields MessageEvent.text and MessageEvent.completed, using msg.channel_type in the reply.
4. Create a ChannelManager with that processor, then call add_feishu_channel, add_qq_channel, and add_dingtalk_channel with their config objects.
5. Send a test message from each platform and confirm the reply includes the channel type.

### Prompt to paste into your agent

```text
In the TencentCloud/octop-gateway repo, build a ChannelManager that attaches Feishu, QQ, and DingTalk channels to one processor using credentials from my .env file. Expected output: a running process that replies to a test message from each platform with the channel type in brackets. Verify that all three channels start without errors in the logs.
```

### Caveat

Each platform needs its own app or bot set up in its developer console, which the README does not walk through.

Risk, credentials: Feishu, QQ, and DingTalk app secrets and tokens grant access to live accounts and must stay in .env, not in code.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/tencentcloud-octop-gateway/one-agent-across-feishu-dingtalk-qq/

## How to stream an LLM agent's reply token by token into chat with Octop Gateway

Repo: [TencentCloud/octop-gateway](https://github.com/TencentCloud/octop-gateway) | Difficulty: Intermediate | Time: 1 hour | Basis: From the README

Use DELTA events and a final COMPLETED event so users see the answer as it is generated.

**Who it is for:** A developer whose agent produces long answers and who wants users to see text appear live in IM.

**The problem:** Waiting for a full answer before sending makes chat feel slow, especially for long responses.

**The outcome:** A processor that yields DELTA events as tokens arrive and a COMPLETED event at the end, with the reply appearing progressively in the IM client.

### Steps

1. Run `pip install octop-gateway` in a Python 3.12+ environment.
2. Write an async generator processor that takes InboundMessage and yields MessageEvent objects.
3. Inside the processor, yield a DELTA event for each token from your model, then yield a COMPLETED event when the stream ends.
4. Wrap the processor in a ChannelManager and attach one channel, such as Telegram, using its config class.
5. Send a prompt that asks for a long answer and confirm the reply updates while it is generated.

### Prompt to paste into your agent

```text
Using the octop-gateway repo, write an async processor that streams tokens from <model client> as MessageEvent DELTA events and ends with COMPLETED, then attach it to a Telegram channel. Expected output: a chat reply that grows over time for a long prompt. Verify that an ERROR event is never yielded for a normal run.
```

### Caveat

The README says DELTA streams tokens, but whether each platform shows partial text live depends on that platform's behavior, so test on your target channel.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/tencentcloud-octop-gateway/stream-llm-tokens-to-chat/

## How to create QQ Bot credentials by scanning a QR code with Octop Gateway

Repo: [TencentCloud/octop-gateway](https://github.com/TencentCloud/octop-gateway) | Difficulty: Intermediate | Time: 45 minutes | Basis: From the README

Use QQBotQRLogin to get QQ Bot credentials without copying an AppID and AppSecret by hand.

**Who it is for:** A developer setting up a QQ Bot for a project who wants to avoid copying secrets manually.

**The problem:** Copying AppID and AppSecret from a console is error-prone and exposes secrets in more places than needed.

**The outcome:** A QQ channel config built from QR-confirmed credentials, ready to attach to a ChannelManager.

### Steps

1. Run `pip install octop-gateway` in a Python 3.12+ environment.
2. Call QQBotQRLogin(source="octop") and then fetch_qr_code() to get a qrcode_url.
3. Render the qrcode_url as a QR code in your UI or terminal and wait for confirmation with wait_for_login(qr.task_id).
4. If result.connected is true, build the config with QQConfig.from_qr_credentials(result.credentials[0]).
5. Store the returned channel config yourself, since the README says persistence is the caller's responsibility.

### Prompt to paste into your agent

```text
In the TencentCloud/octop-gateway repo, run the QQ Bot QR binding flow with QQBotQRLogin, print the qrcode_url for <user>, and wait for confirmation. Expected output: a QQConfig object built from result.credentials[0] and saved to <config store>. Verify that result.connected is true before building the config.
```

### Caveat

The one-time decryption key is kept only in memory and discarded after success, expiry, cancellation, or timeout, so a failed run means restarting the QR flow.

Risk, credentials: The QR flow returns live QQ Bot credentials, so the saved config must be stored in a secret store with restricted access.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/tencentcloud-octop-gateway/bind-qq-bot-by-qr-code/

## How to run two Feishu apps for two teams in one process with Octop Gateway

Repo: [TencentCloud/octop-gateway](https://github.com/TencentCloud/octop-gateway) | Difficulty: Intermediate | Time: 45 minutes | Basis: From the README

Register two channels of the same kind with separate credentials and keep them isolated.

**Who it is for:** An operator supporting two internal teams that each need their own Feishu app and bot.

**The problem:** Running two bots in separate processes doubles deployment work, and mixing them in one channel leaks context between teams.

**The outcome:** One process with two Feishu channels, each isolated by its channel_id and tied to its own app credentials.

### Steps

1. Run `pip install octop-gateway` in a Python 3.12+ environment.
2. Create two FeishuConfig objects, one for each team's app_id and app_secret.
3. Create one ChannelManager with a shared processor and call add_feishu_channel once for each config.
4. Send a test message to each team's bot and check the replies come from the matching channel.

### Prompt to paste into your agent

```text
In the TencentCloud/octop-gateway repo, create one ChannelManager with two Feishu channels using credentials for <team A> and <team B> from environment variables. Expected output: two channels running side by side with distinct channel_id values. Verify that a message to team A's bot never appears on team B's channel.
```

### Caveat

The README says channels are isolated by channel_id, but it does not describe how to set a custom channel_id, so check the generated ids in the startup logs.

Risk, credentials: Each team's Feishu app secret must be stored separately so one team's credentials are not exposed to the other.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/tencentcloud-octop-gateway/isolate-two-feishu-teams/
