Build a Proactive AI Shopping Guide in 10 Minutes with Multi‑Agent Architecture
This tutorial demonstrates how to create a 10‑minute, no‑code AI shopping guide on Alibaba Cloud using a multi‑agent system, covering architecture, step‑by‑step deployment, key code snippets, and production tips for extending the solution to other scenarios.
Background
AI customer‑service bots are common on websites, messaging apps, and enterprise platforms. This article explains how to build a proprietary AI assistant that can proactively ask questions and recommend products, all within ten minutes on Alibaba Cloud without writing code.
Architecture Overview
The solution uses a Multi‑Agent architecture:
Router Agent – classifies user intent and routes the conversation to the appropriate domain‑specific guide.
Mobile Phone, TV, and Refrigerator Guide Agents – interact with the user to collect product parameters and provide recommendations.
Conversation History – stored for each agent to inform decisions.
When a user asks about a product, the Router Agent selects the relevant guide agent, which then asks for specifications and finally presents a recommendation.
Step‑by‑Step Guide
Create a Function Compute application using the prepared template, fill in your API‑Key (and optionally a Baileian app ID), and deploy. Deployment takes about one minute.
After deployment, open the provided domain to verify the website is running.
Interact with the smart guide; it will proactively ask for product parameters and display the collected information.
Key Code Snippets
ROUTER_AGENT_INSTRUCTION = """
你是一个问题分类器
请结合用户的提问和上下文判断用户是希望了解的商品具体类型。
注意,你的输出结果只能是下面列表中的某一个,不能包含任何其他信息:
- 手机
- 电视机
- 冰箱
- 其他
"""
router_agent = Assistants.create(
model="qwen-plus",
name='引导员,路由器',
description='你是一个商城的引导员,负责将用户问题路由到不同的导购员。',
instructions=ROUTER_AGENT_INSTRUCTION
) MOBILEPHONE_GUIDE_AGENT_INSTRUCTION = """
你是负责给顾客推荐手机的智能导购员。
你需要按照下文中【手机的参数列表】中的顺序来主动询问用户需要什么参数的手机,一次只能问一个参数,不要对一个参数进行重复提问。
...(省略其余指令)"""
mobilephone_guide_agent = Assistants.create(
model="qwen-max",
name='手机导购',
description='你是一个手机导购,你需要询问顾客想要什么参数的手机。',
instructions=MOBILEPHONE_GUIDE_AGENT_INSTRUCTION
) FRIDGE_GUIDE_AGENT_INSTRUCTION = """
你是负责给顾客推荐冰箱的智能导购员。
你需要按照下文中【冰箱的参数列表】中的顺序来主动询问用户需要什么参数的冰箱,一次只能问一个参数,不要对一个参数进行重复提问。
...(省略其余指令)"""
fridge_guide_agent = Assistants.create(
model="qwen-max",
name='冰箱导购',
description='你是一个冰箱导购,你需要询问顾客想要什么参数的冰箱。',
instructions=FRIDGE_GUIDE_AGENT_INSTRUCTION
) agent_map = {
"意图分类": router_agent.id,
"手机": mobilephone_guide_agent.id,
"冰箱": fridge_guide_agent.id,
"电视机": tv_guide_agent.id
}
def chat(input_prompt, thread_id):
router_agent_response = get_agent_response(agent_name="意图分类", input_prompt=input_prompt, thread_id=thread_id)
classification_result = parse_streaming_response(router_agent_response)
response_json = {"content": ""}
if classification_result == "其他":
response_json["content"] = "不好意思,我没有理解您的问题,能换个表述方式么?"
response_json["current_agent"] = classification_result
response_json["thread_id"] = thread_id
yield f"{json.dumps(response_json)}
"
else:
agent_response = get_agent_response(agent_name=classification_result, input_prompt=input_prompt, thread_id=thread_id)
for chunk in agent_response:
response_json["content"] = chunk
response_json["current_agent"] = classification_result
response_json["thread_id"] = thread_id
yield f"{json.dumps(response_json)}
"Conclusion
By following these steps you have built a cloud‑based AI shopping guide that operates 24/7 and can be adapted to other use cases such as intelligent diagnosis or job recommendation.
Production Tips
Replace the knowledge base with your own product catalog or integrate a database for real‑time queries.
Modify the prompts in prompt.py and agents.py to suit your business logic.
Deploy the updated code and monitor usage.
Download the free ebook “10 Minutes to Build Your Own AI Assistant” for the complete tutorial and additional examples.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Developer
Alibaba's official tech channel, featuring all of its technology innovations.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
