日本語での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
- SimpliAgentic —— 新一代自律智能工厂,从这里开始
- SimpliAgentic — The Future of Autonomous Factory Automation Has Arrived
- 为什么理解 Android Internals(安卓内部机制)如此重要?——帮助企业打造高价值系统级服务
- Why Android Internals Matter — And the High-Value Services Your Business Can Build With Them
- 为什么企业应该开发自己的电商系统(而不是依赖租用型平台)
- Why Your Business Should Build Its Own E-Commerce System (Instead of Renting One)
- Upstream、Downstream 和 Fork:Android 与 Linux 开发者必须理解的核心概念
- Upstream, Downstream, and Fork: A Clear Guide for Android & Linux Developers
- NVIDIA、Microsoft、OpenAI、Google、Oracle 以及 AMD:正在共同推动 AI 泡沫如何形成?
- The Real AI Bubble: How NVIDIA, Microsoft, OpenAI, Google, Oracle — and Now AMD — Shape the Future of Compute
- 深度学习在房地产开发中的应用
- Deep Learning in Property Development
- 代码修复与遗留系统维护服务 —— Simplico 助力企业保持系统稳定、安全、高效
- Code Fixing & Legacy System Maintenance — Keep Your Business Running Smoothly with Simplico
- Python 深度学习在工厂自动化中的应用:2025 全面指南
- Python Deep Learning in Factory Automation: A Complete Guide (2025)
- 工厂 / 制造业专用 Python 开发与培训服务
- Python Development & Industrial Automation Training Services
- 为什么 Python + Django 是现代电商系统的最佳技术栈(完整指南 + 定价方案)
- Why Python + Django Is the Best Tech Stack for Building Modern eCommerce Platforms (Complete Guide + Pricing Plans)













