×
Community Blog Unlock the Power of Conversational AI: Create Your Own Chatbot Using Qwen, Model Studio, and FC

Unlock the Power of Conversational AI: Create Your Own Chatbot Using Qwen, Model Studio, and FC

This blog describes the process of creating your very own chatbot using these cutting-edge technologies.

Written by M Fakhri Darmawan, Solution Architect Alibaba Cloud Indonesia

In today’s fast-paced digital world, chatbots have become indispensable tools for businesses and developers looking to enhance user experiences, automate workflows, and scale customer interactions. But what if you could build a highly intelligent, customizable chatbot tailored to your exact needs? Enter Qwen, Alibaba Cloud’s state-of-the-art large language model, combined with the robust capabilities of Model Studio and Function Compute (FC). In this blog, we’ll guide you step-by-step through the process of creating your very own chatbot using these cutting-edge technologies—empowering you to harness the full potential of conversational AI without breaking a sweat.

Step 1

Activate Model Studio with no cost using this LINK. Next is create API Key.

Step 2

Create and Get API Key

1.  Hover your cursor over 1 in the upper-right corner of the page and select API-KEY.

2

2.  In the left-side navigation pane, select All API Keys or My API Key to view or create API keys. Click Create My API Key or View existing APi keys.

3

Note

  • You can only use the All API Keys page if you are using the Alibaba Cloud account. The Alibaba Cloud account can obtain the API keys of all RAM users, but a RAM user can only obtain its own API key.
  • Keep your API key confidential to avoid security risks or financial losses caused by unauthorized usage.
  • You API key is an important asset, make sure to keep it safe. If you click Delete in the Actions column to delete an existing API Key, you cannot use the key to use Model Studio services again. All applications or services associated with this key will fail.

Step 3

Create and Deploy Model Studio Application

Agent application - Alibaba Cloud Model Studio - Alibaba Cloud Documentation Center

Step 4

Get Application ID

Obtain application ID and workspace ID - Alibaba Cloud Model Studio - Alibaba Cloud Documentation Center

Step 5

Deploy Chatbot Sample Application

Prerequisite

Steps

1.  Download code from this github repository.

2.  Unzip the code

3.  Change code in s.yaml file

edition: 3.0.0
name: fc3-example
access: default
resources:
  fcDemo:
    component: fc3
    props:
      region: ap-southeast-1
      handler: handler
      role: ''
      disableOndemand: false
      description: web-chatbot
      timeout: 180
      internetAccess: true
      layers:
        - acs:fc:ap-southeast-1:official:layers/Nodejs16/versions/2
      customRuntimeConfig:
        args:
          - run
          - start
        port: 9000
        command:
          - npm
      # logConfig: # define log project in sls to enable log for your FC
      #   enableRequestMetrics: true
      #   enableInstanceMetrics: true
      #   logBeginRule: DefaultRegex
      #   project: serverless-ap-southeast-5-xxx
      #   logstore: default-logs
      functionName: webchat-bot
      runtime: custom
      instanceConcurrency: 1
      memorySize: 128
      environmentVariables:
        PATH: >-
          /opt/nodejs16/bin:/usr/local/bin/apache-maven/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ruby/bin:/opt/bin:/code:/code/bin
        BAILIAN_APP_ID: 386XXX # put your model studio application id here
        BAILIAN_API_KEY: sk-xxx #put your API Key here or in FC Configuration -> Environment variable
        LD_LIBRARY_PATH: >-
          /code:/code/lib:/usr/local/lib:/opt/lib:/opt/php8.1/lib:/opt/php8.0/lib:/opt/php7.2/lib
        STATIC_DIR: /public
        NODE_PATH: /opt/nodejs/node_modules
        SECRET: ''
      code: ./webchat-bot-fd
      triggers:
        - triggerConfig:
            methods:
              - GET
              - POST
              - PUT
              - DELETE
              - HEAD
              - PATCH
            authType: anonymous
            disableURLInternet: false
          triggerName: httpTrigger
          description: ''
          qualifier: LATEST
          triggerType: http

Code need to change :

a) Line 37. “ BAILIAN_APP_ID: 386XXX # put your model studio application id here “

b) Line 38. “ BAILIAN_API_KEY: sk-xxx #put your API Key here or in FC Configuration -> Environment variable ”

4.  Deploy the code using serverless deployment

s deploy s.yaml

Result if the deployment succeeds

[2025-03-14 17:08:53][WARN][s_cli] It is not recommended to run the command as root user.
(node:56555) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
⌛  Steps for [deploy] of [fc3-example]
====================
disableOndemand: false

* You can also specify to use local configuration through --assume-yes/-y during deployment
? Deploy it with local config? Yes
(node:56555) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

TIPS:

You can use "s info" get more detail

✔ [fcDemo] completed (14.88s)

🚀  Result for [deploy] of [fc3-example]
====================
region:               ap-southeast-1
customRuntimeConfig: 
  args: 
    - run
    - start
  command: 
    - npm
  port:    9000
description:          web-chatbot
environmentVariables: 
  BAILIAN_API_KEY: sk-xxx
  BAILIAN_APP_ID:  386b4ab2a301472688b3e35906a15fe1
  LD_LIBRARY_PATH: /code:/code/lib:/usr/local/lib:/opt/lib:/opt/php8.1/lib:/opt/php8.0/lib:/opt/php7.2/lib
  NODE_PATH:       /opt/nodejs/node_modules
  PATH:            /opt/nodejs16/bin:/usr/local/bin/apache-maven/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ruby/bin:/opt/bin:/code:/code/bin
  SECRET:          
  STATIC_DIR:      /public
functionArn:          acs:fc:ap-southeast-1:5846842125303498:functions/webchat-bot
functionName:         webchat-bot
handler:              handler
instanceConcurrency:  1
internetAccess:       true
layers: 
  - acs:fc:ap-southeast-1:official:layers/Nodejs16/versions/2
memorySize:           128
role:                 
runtime:              custom
timeout:              180
triggers: 
  - 
    description:   
    qualifier:     LATEST
    triggerConfig: 
      methods: 
        - GET
        - POST
        - PUT
        - DELETE
        - HEAD
        - PATCH
      authType:           anonymous
      disableURLInternet: false
    triggerName:   httpTrigger
    triggerType:   http
url: 
  system_url:          https://webchat-bot-usebaqmcxe.ap-southeast-1.fcapp.run
  system_intranet_url: https://webchat-bot-usebaqmcxe.ap-southeast-1-vpc.fcapp.run
__component:          fc3

5.  Ensure the FC was deployed and environment variable was configured correctly

4
5

6.  Add your domain

6

Put your domain, select your function and version, then create the application

7

Configure your domain and pointing to CNAME from Function Compute

7.  Go to your domain and test the application and try using your own promt

8

Benefits:

Easy Deployment: No need to manage servers; Function Compute handles scaling and infrastructure.

Customizable: Model Studio allows you to tailor Qwen to your specific business requirements.

Cost-Effective: Pay only for the compute resources used during conversations.

Use Cases:

• Customer support automation.

• Virtual assistants for websites or apps.

• Interactive FAQ bots.

This setup combines Qwen's powerful conversational AI, Model Studio's customization capabilities, and Function Compute's scalability to create a flexible and efficient chatbot solution.

0 1 0
Share on

Alibaba Cloud Indonesia

110 posts | 20 followers

You may also like

Comments

Alibaba Cloud Indonesia

110 posts | 20 followers

Related Products