×
Community Blog Complete Beginner's Guide: Building Your First AI Agent on Alibaba Cloud

Complete Beginner's Guide: Building Your First AI Agent on Alibaba Cloud

This article serves as a comprehensive beginner's guide to building a personalized AI meal planner on Alibaba Cloud.

Picture this: It's 6 PM, you're tired from work, and you ask your phone "What should I make for dinner tonight?" Instead of generic results, you get a personalized response: "Based on your preferences, how about that Mediterranean chicken bowl you loved last month? I can adjust it for the ingredients you have at home."

That's exactly what you're building today—an AI assistant that knows YOU. Not just any meal planner, but your meal planner.

Your custom AI chef will:

● Learn your unique taste preferences through natural conversation

● Remember your dietary restrictions, favorite cuisines, and cooking skill level

● Suggest meals based on your mood, schedule, and available ingredients

● Keep a personal database of recipes you've tried and loved

● Evolve its recommendations as your tastes and needs change

Step 1: Set Up Your First Project

1.1 Access the Console

Log into your Alibaba Cloud Console and look for the search bar at the top (This is where we'll find all the services we need)

1.2 Create a Resource Group (Optional but Recommended)

1.  In the search bar, type: Resource Management

2.  Click on Resource Management from the dropdown

3.  Click Resource Groups in the left menu

4.  Click Create Resource Group

5.  Fill in:

  • Name: my-first-ai-agent
  • Display Name: My First AI Agent

6.  Click OK

Why do this? It keeps all your project resources organized and makes cleanup easier.

Step 2: Enable Required Services

We need to "turn on" the services we'll use. Think of this like installing apps on your phone.

2.1 Enable Alibaba Cloud Model Studio (The AI Brain)

  1. In the console search bar, type: Model Studio
  2. Click on Alibaba Cloud Model Studio when it appears
  3. If you see an Activate Service button, click it
  4. Accept the terms and conditions
  5. Wait for activation (usually instant)

Note: Model Studio is the unified platform that provides AI capabilities through DashScope.

2.2 Enable Function Compute (The Server)

  1. Search for: Function Compute
  2. Click on Function Compute
  3. Click Activate Service if prompted
  4. Accept terms and wait for activation

2.3 Enable API Gateway (The Front Door)

  1. Search for: API Gateway
  2. Click on API Gateway
  3. Activate the service if needed

Checkpoint: You should see all three services in your console without Activate buttons

Step 3: Get Your API Keys (Critical Step!)

Your AI agent needs keys to access Alibaba Cloud services. Think of these like passwords.

3.1 Get Your DashScope API Key (Most Important!)

1.  Go back to Alibaba Cloud Model Studio service

2.  In the left menu, look for one of these options:

  • "API Keys"
  • "Credentials"
  • "Console" → "API Management"
  • "Workspace" → "Settings"

3.  Click Create API Key or Generate API Key

4.  IMPORTANT: Copy the API key and save it safely

5.  The key should look like: sk-xxxxxxxxxxxxxxxxxxxxxxxxx

This is the most critical step! Without this API key, your AI won't work.

3.2 Create Access Keys (For Function Compute)

  1. Click on your profile picture in the top right corner
  2. Select "AccessKey Management"
  3. Click "Create AccessKey"
  4. IMPORTANT: Copy both the Access Key ID and Secret Access Key
  5. Save them in a text file - you'll need them later!

⚠️ Security Note: Never share these keys publicly or put them in forums/chat!

Step 4: Create Your Function Compute Service

Create Your Function

1.  Go to Function Compute in your console

2.  Click Functions in the left menu

3.  Click Create Function

4.  Choose Create from scratch

5.  Fill in:

  • Function Name: meal-planner-bot
  • Runtime: Python 3.9 or Python 3.10
  • Handler: app.handler
  • Memory: 512 MB
  • Timeout: 60 seconds

6.  Click Create

Checkpoint: You should now have a function ready for code!

Step 5: Add Your AI Code (15 minutes)

5.1 Upload the Code

  1. In your function, click Code tab
  2. Delete all existing code in the editor
  3. Copy and paste this complete code from the following repo: https://github.com/FarahAbdo/meal-planner-agent
  4. Click Deploy to save your code

1

5.2 Configure Environment Variables (Critical!)

1.  In your function, click Configuration tab

2.  Find Environment Variables section

3.  Click Edit or Add Environment Variable

4.  Add:

  • Key: MODEL_STUDIO_API_KEY
  • Value: Your DashScope API key from Step 3.1

5.  Click Save

⚠️ This step is essential! Without the environment variable, your AI won't work.

Step 6: Test Your Function

6.1 Basic Test

1.  In your function, click Test tab

2.  Create a new test event:

  • Event Name: meal-planning-test
  • Event Body: Replace with this JSON:

2

3.  Click Test

6.2 Expected Results

Success: You should see a response like:

3

6.3 Troubleshooting Common Issues

If you get API key errors:

● Double-check your DashScope API key in Model Studio

● Make sure the environment variable is set correctly

● Redeploy your function after adding the environment variable

If you get parsing errors:

● Check that your test JSON is properly formatted

● Make sure you're using the exact JSON structure shown above

If you get timeout errors:

● Your function might need more time to process

● Go to Configuration → Basic Settings and increase timeout to 60 seconds

Step 7: Create a Simple Web Interface

What you'll build: A basic HTML page with a chat interface

Key features:

● Simple text input and send button

● Chat history display

● Real-time messaging with your AI bot

● Responsive design that works on mobile

Technologies: HTML, CSS, JavaScript

Hosting: Upload to Function Compute for static hosting

Step 8: Deploy with API Gateway

What you'll accomplish: Make your bot accessible via a public URL

Key features:

● Create API Gateway instance

● Configure HTTP triggers

● Set up custom domain (optional)

● Enable HTTPS and security headers

● Test public endpoint

Outcome: Your bot will have a public URL like https://your-bot.alibabacloud.com

Step 9: Add Conversation Memory

What you'll enhance: Help your bot remember previous conversations

Key features:

● Store conversation history in TableStore

● Implement session management

● Context-aware responses

● User preference persistence

● Conversation threading

Technologies: TableStore (NoSQL database)

Step 10: Enhanced Meal Planning Features

What you'll add: More sophisticated meal planning capabilities

Key features:

● Weekly meal planning

● Grocery list generation

● Nutritional analysis

● Recipe scaling (serves 2 vs serves 4)

● Seasonal ingredient suggestions

● Integration with nutrition APIs

AI Models: Advanced prompting techniques, function calling

🎉 Congratulations - You've Built Your First AI Agent!

You've just transformed from a complete beginner to someone who can build, deploy, and enhance AI-powered applications on Alibaba Cloud. Your meal planning bot isn't just a tutorial project—it's a foundation you can build upon.

What you've mastered:

● Setting up cloud infrastructure from scratch

● Integrating AI models with real applications

● Building user-friendly interfaces

● Managing conversation state and memory

● Deploying production-ready services

Disclaimer: The views expressed herein are for reference only and don't necessarily represent the official views of Alibaba Cloud.

0 2 1
Share on

Farah Abdou

12 posts | 0 followers

You may also like

Comments

Farah Abdou

12 posts | 0 followers

Related Products