Artificial Intelligence 22 min read

Step-by-Step Guide to Creating Custom Coze Plugins for AI Bots

This article provides a comprehensive tutorial on building, configuring, testing, publishing, and listing custom Coze plugins for AI bots, covering both creation from existing services and direct development in Coze IDE with code examples and practical tips.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Step-by-Step Guide to Creating Custom Coze Plugins for AI Bots

1. Introduction

While browsing, I discovered that Juejin has launched a new "Bot Activity" – the Code Infinity: AI Bot Technical Challenge (https://juejin.cn/post/7355439624100249635). At the same time, Coze released a new "Plugin IDE" feature, and the documentation now includes a section on the "Code node" with built‑in third‑party dependencies.

The competition requires participants to create a Bot (not a pure prompt Bot) that uses plugins, workflows, or knowledge bases, and to publish it on the Coze Store and Juejin platform. Articles must include Bot description, design, technical implementation, use cases, and commercial analysis, with the Bot ID appended.

The award criteria include the "AI Bot Technical Pioneer" award (must have a self‑developed plugin) and the "AI Bot Creative Spark" and "AI Bot Technical Light" awards (extra points for self‑developed workflow/plugin).

Developing a custom plugin is a practical way to increase winning chances; the core of a plugin is simply an API wrapper.

2. Creating a Plugin from Existing Services

First, select an external API and configure the call rules:

Plugin – specify BaseURL and default request headers.

Plugin Tool – specify the endpoint, input, and output parameters.

A plugin tool is a subset of a plugin; calling different tools under the same plugin essentially calls different endpoints under the same domain.

2.1. Create the Plugin

Navigate to the "Workspace", choose a team or personal space, click "Plugin", then "Create Plugin" and fill in the configuration:

Plugin icon – upload a custom icon.

Plugin name – a clear, descriptive name.

Plugin description – brief purpose of the plugin.

Plugin tool creation method – select "Create from existing service".

Plugin URL – the API endpoint (e.g., www.example.com/api).

Header list – HTTP request headers required by the API.

Authorization – choose none, Service (key/token), or OAuth.

2.2. Create a Plugin Tool

After confirming the plugin, click "Create Tool" and fill in basic information (example uses WanAndroid API). Configure input parameters (e.g., a "page" parameter for pagination) and output parameters (auto‑parse is recommended).

2.3. Publish the Plugin

Click the "Publish" button, fill in the personal‑information statement (or skip), and confirm. The plugin status changes to "Published".

2.4. List the Plugin

If the plugin was created in a personal space, only you can call it; in a team space, only team members can. To make it publicly searchable, you must also "List the Plugin" in the store.

2.5. Ways to Find API Sources

Free/open‑source APIs (e.g., WanAndroid, Bilibili API collections).

Paid APIs (e.g., Juhe data, GPT third‑party providers) with free‑call quotas.

API scraping or reverse‑engineering (use with caution).

Mock APIs that return static responses.

Self‑hosted APIs on a cloud server (higher cost and setup effort).

Coze IDE – an online coding environment that hosts your plugin code without manual deployment.

3. Creating a Plugin Directly in Coze IDE

3.1. Overview

Click "Create Plugin", enter name and description, choose "Create in Coze IDE", select Python3 as the runtime, and confirm.

In the IDE, click "Create Tool", provide tool name and description, then open the code editor.

Configure input and output parameters under "Metadata". The code editor includes a default "async_requests" library; you can also use the standard "requests" library.

After installing dependencies, write simple code, e.g., printing the user‑provided ID.

The IDE offers an AI assistant that can generate, modify, explain, or document code (triggered with Ctrl+I).

Important notes: do not delete or modify the template handler method, and the return value must be a JSON object.

3.2. Practical Example: Query Juejin Author Articles

Import the requests library and call the Juejin article list API:

from runtime import Args
from typings.user_article_list.user_article_list import Input, Output
import requests

def fetch_artcile_infos(user_id, cursor):
    request_json = {"user_id": user_id, "sort_type": 2, "cursor": str(cursor)}
    resp = requests.post("https://api.juejin.cn/content_api/v1/article/query_list", json=request_json)
    return resp.text

def handler(args: Args[Input]) -> Output:
    input_user_id = args.input.user_id
    input_cursor = args.input.cursor
    result = fetch_artcile_infos(input_user_id, input_cursor)
    return {"message": str(result)}

After testing, configure output parameters to return a list of article objects. A more complete implementation extracts fields such as title, brief content, view count, tags, and link URL:

from runtime import Args
from typings.user_article_list.user_article_list import Input, Output
import requests

request_headers = {
    "Origin": "https://juejin.cn",
    "Referer": "https://juejin.cn/editor/drafts/new?v=2",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
}

class ArticleInfo:
    def __init__(self, title=None, brief_content=None, view_count=0, collect_count=0, digg_count=0,
                 comment_count=0, tags=None, link_url=None):
        self.title = title
        self.brief_content = brief_content
        self.view_count = view_count
        self.collect_count = collect_count
        self.digg_count = digg_count
        self.comment_count = comment_count
        self.tags = tags
        self.link_url = link_url

    def to_json(self):
        return {
            "title": self.title,
            "brief_content": self.brief_content,
            "view_count": self.view_count,
            "collect_count": self.collect_count,
            "digg_count": self.digg_count,
            "comment_count": self.comment_count,
            "tags": self.tags if self.tags else [],
            "link_url": self.link_url
        }

def fetch_artcile_infos(user_id, cursor):
    request_json = {"user_id": user_id, "sort_type": 2, "cursor": str(cursor)}
    resp = requests.post("https://api.juejin.cn/content_api/v1/article/query_list", headers=request_headers, json=request_json)
    article_info_list = []
    if resp:
        article_info = resp.json()
        if article_info and article_info["data"]:
            for article in article_info["data"]:
                article_info_list.append(
                    ArticleInfo(
                        title=article["article_info"]["title"],
                        brief_content=article["article_info"]["brief_content"],
                        view_count=article["article_info"]["view_count"],
                        collect_count=article["article_info"]["collect_count"],
                        digg_count=article["article_info"]["digg_count"],
                        comment_count=article["article_info"]["comment_count"],
                        tags=list(map(lambda x: x["tag_name"], article["tags"])),
                        link_url="https://juejin.im/post/" + article["article_id"]
                    ).to_json()
                )
    return article_info_list

def handler(args: Args[Input]) -> Output:
    input_user_id = args.input.user_id
    input_cursor = args.input.cursor
    result = fetch_artcile_infos(input_user_id, input_cursor)
    return {"article_list": result}

After successful testing, click "Publish" and wait for approval. Once approved, the plugin appears in the store and can be used by others.

4. Appendix: Using Mock API to Implement Custom Interfaces

A Mock API simulates real API behavior by returning predefined data, useful for front‑end development without a backend.

In ApiFox, create a workspace, enable "Cloud Mock", define an endpoint (e.g., /pet/1), and set static response data. You can also configure conditional responses based on request parameters or update the mock data via ApiFox's API.

For detailed steps and code, refer to the author's previous article "Coze Official Plugin Not Enough? Build Your Own (Free)" (https://juejin.cn/post/7340826749096230951#heading-4).

Plugin Tool Name

Belongs To

Function

DayWeather

墨迹天气

Get weather for a specific date

getRoute

飞常准

Get flight list

SearchHotels

猫途鹰

Search hotels by city, check‑in/out dates

(The rest of the rows are omitted for brevity)

PythonCozeplugin developmentAPI IntegrationAI Bot
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.