日本語でのRasaを使用したチャットボットの作成
このガイドでは、Rasa を使用して日本語対応のチャットボットを作成し、「ビッグカメラ」などの IT ガジェットショップでの販売をサポートする方法について説明します。
より実践的な連携例については、以下のガイド記事もご覧ください:
👉 チャットボットを強化するための業務API連携サービスの紹介
より詳しい比較記事はこちらもぜひご覧ください:  
RasaとChatGPT Builderの違いを徹底解説(日本語対応編)
さらに、次世代の自律型AIエージェントによる業務変革にも興味がある方はこちら:  
自律型 Agentic AI で業務を変革する方法
ステップ 1: Rasa のインストール
Python がインストールされていることを確認し、pip を使用して Rasa をインストールします。
pip install rasaステップ 2: 新しい Rasa プロジェクトを初期化
新しい Rasa プロジェクトを作成します:
rasa init --no-promptこのコマンドで、デフォルトのプロジェクト構造が生成されます。
ステップ 3: 日本語サポートの追加
config.yml ファイルを編集して、日本語をサポートするようにします。日本語を効果的に処理できるトークナイザーとパイプラインを使用します。
language: ja
pipeline:
  - name: "JiebaTokenizer"
  - name: "RegexFeaturizer"
  - name: "LexicalSyntacticFeaturizer"
  - name: "CountVectorsFeaturizer"
    analyzer: "word"
  - name: "CountVectorsFeaturizer"
    analyzer: "char_wb"
    min_ngram: 1
    max_ngram: 4
  - name: "DIETClassifier"
    epochs: 100
  - name: "EntitySynonymMapper"
  - name: "ResponseSelector"
    epochs: 100
  - name: "FallbackClassifier"
    threshold: 0.3ステップ 4: インテントとレスポンスの定義
domain.yml ファイルに、チャットボットで使用するインテントとレスポンスを定義します。
intents:
  - greet
  - ask_discount
  - ask_camera_features
  - check_stock
  - thank_you
responses:
  utter_greet:
    - text: こんにちは!ビッグカメラ IT ガジェットショップへようこそ!
  utter_ask_discount:
    - text: このカメラは今だけ特別価格で提供されています!どのモデルに興味がありますか?
  utter_ask_camera_features:
    - text: ご希望のカメラの特徴を教えてください。高画質ですか?ズームレンズですか?
  utter_check_stock:
    - text: ご希望のモデル名を教えてください。在庫状況を確認します。
  utter_thank_you:
    - text: ありがとうございます!他に質問があればお気軽にお問い合わせください。ステップ 5: トレーニングデータの作成
data/nlu.yml ファイルに日本語でトレーニングデータを追加します。
version: "3.0"
nlu:
  - intent: greet
    examples: |
      - こんにちは
      - ハロー
  - intent: ask_discount
    examples: |
      - 特別価格の商品はありますか?
      - 値引きはありますか?
  - intent: ask_camera_features
    examples: |
      - このカメラにはどんな特徴がありますか?
      - 高画質のカメラはどれですか?
  - intent: check_stock
    examples: |
      - このモデルは在庫がありますか?
      - 在庫状況を教えてください。
  - intent: thank_you
    examples: |
      - ありがとう
      - 感謝しますステップ 6: カスタムアクションの作成
在庫を確認するカスタムアクションを actions/actions.py ファイルに定義します。
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
class ActionCheckStock(Action):
    def name(self) -> Text:
        return "action_check_stock"
    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        # 在庫情報の例
        stock_data = {
            "camera_x": "在庫あり",
            "camera_y": "在庫なし",
        }
        model = tracker.get_slot("camera_model")
        if model in stock_data:
            stock_status = stock_data[model]
            response = f"モデル {model} の在庫状況: {stock_status}"
        else:
            response = "指定されたモデルは見つかりませんでした。"
        dispatcher.utter_message(text=response)
        return []domain.yml ファイルを更新して、カスタムアクションとスロットを追加します。
actions:
  - action_check_stock
slots:
  camera_model:
    type: textステップ 7: ストーリーの作成
在庫確認のストーリーを data/stories.yml に追加します。
version: "3.0"
stories:
  - story: Check Stock
    steps:
      - intent: check_stock
      - action: utter_check_stock
      - slot_was_set:
          - camera_model: "camera_x"
      - action: action_check_stockステップ 8: チャットボットのテスト
以下のコマンドを使用してチャットボットを実行します。
rasa train
rasa shell日本語でテストメッセージを入力して動作を確認します。
ステップ 9: チャットボットのデプロイ
Rasa X を使用するか、ウェブインターフェースと統合してチャットボットをデプロイします。
ステップ 10: 継続的な改善
チャットボットのパフォーマンスを分析し、トレーニングデータを最適化して、さまざまなユーザーの問い合わせに対応できるようモデルを改善します。
Rasa のワークフロー
以下は、Rasa のワークフローを MermaidJS で視覚化したものです。
graph TD
    User[ユーザー入力] -->|メッセージ送信| NLU[NLU パイプライン]
    NLU -->|インテントとエンティティを分類| Core[Rasa Core]
    Core -->|ポリシーに従う| Action[アクションサーバー]
    Action -->|カスタムアクションまたはレスポンスを実行| Bot[ボットレスポンス]
    Bot -->|ユーザーに返信| User
    subgraph Rasa システム
        NLU
        Core
        Action
    endこのガイドを参考に、日本語対応の Rasa チャットボットを作成して、「ビッグカメラ」や他の IT ガジェットショップの販売を支援してください。
Get in Touch with us
Related Posts
- How Agentic AI and MCP Servers Work Together: The Next Step in Intelligent Automation
- DevOps in Django E-Commerce System with DRF and Docker
- How AI Can Solve Real Challenges in Agile Development
- Connecting TAK and Wazuh for Real-Time Threat Awareness
- Scaling Wazuh for Multi-Site Network Security Monitoring
- Why ERP Projects Fail — and How to Avoid It
- How to Build Strong Communities with Technology
- How AI Can Make Open Zoos More Fun, Smart, and Educational
- How to Choose the Right Recycling Factory for Industrial Scrap
- Understanding Modern Database Technologies — and How to Choose the Right One
- The Future Is at the Edge — Understanding Edge & Distributed Computing in 2025
- NVIDIA and the Two Waves: From Crypto to AI — The Art of Riding a Bubble
- From Manual Checks to AI-Powered Avionics Maintenance
- Automated Certificate Generator from XLSX Templates
- Introducing SimpliPOS (COFF POS) — A Café-Focused POS System
- Building a Local-First Web App with Alpine.js — Fast, Private, and Serverless
- Carbon Footprint Calculator (Recycling) — Measuring CO₂ Savings in Recycling Operations
- Recycle Factory Tools: A Smarter Way to Track Scrap Operations
- Running Form Coach — Cadence Metronome, Tapper, Drills, Posture Checklist
- How to Build a Carbon Credit Calculator for Your Business

 
          











