opendialogai/webchat

Open Dialog项目的前端Web聊天组件

该软件包的规范存储库似乎已不存在,因此软件包已被冻结。

安装次数: 12,651

依赖项: 0

建议者: 0

安全: 0

星标: 15

关注者: 8

分叉: 4

开放问题: 11

语言:CSS

1.18.0 2023-07-11 13:49 UTC

This package is auto-updated.

Last update: 2023-07-11 13:52:56 UTC


README

CircleCI

这是OpenDialog webchat软件包,其中包含基于Vue的webchat机器人、API和数据库配置。

本地开发设置

该应用程序旨在使用OpenDialog开发环境进行开发。请遵循那里的说明来设置容器。测试应在workspace容器内运行。

运行代码检查器

要运行代码检查器,请运行以下命令 ./vendor/bin/phpcs --standard=od-cs-ruleset.xml src/ --ignore=*/migrations/*,*/tests/*

Git钩子

要设置包含的git pre-commit钩子,首先确保pre-commit脚本是可执行的,运行

chmod +x .githooks/pre-commit

然后通过运行以下命令配置您的本地git以使用此目录作为git钩子目录

git config core.hooksPath .githooks/

现在,您所做的每个提交都将触发php codesniffer运行。如果代码格式存在问题,脚本将输出php codesniffer的输出。如果没有问题,提交将进入git。

在应用程序中使用此软件包的步骤

Composer设置

要使用Composer安装,请运行以下命令

composer require opendialogai/webchat

构建前端资源

资源CI构建

该项目已设置,以便cssjsimage资源不会被从开发人员的机器上推送(它们是.gitignore的一部分,以确保)。相反,它们由CI过程在每个提交时构建和推送。

要忽略已构建资源的本地更改,请运行

git update-index --assume-unchanged public/css/app.css public/css/app-fullpage.css public/css/app-iframe.css public/css/main.css public/js/app.js public/js/opendialog-bot.js public/js/opendialog-bot-full.js

手动构建资源

在开发时构建资源,请按照以下流程操作

  • 切换到vendor/opendialog/webchat-frontend目录,并运行yarn install; yarn dev(用于开发)

  • 运行php artisan vendor:publish --tag=public --force将新构建的资源移动到父应用程序中进行服务

发布迁移文件

迁移文件需要在应用到OpenDialog应用的数据库之前发布。要发布迁移,请运行:php artisan vendor:publish --tag="od-webchat-migrations" 如果作为多租户系统运行,则此操作依赖于在应用的.env文件中将MULTI_TENANT环境变量设置为true,以确保迁移最终落在正确的位置

配置

WebChat配置可以在webchat_settings表中找到。在运行之前,应该通过运行以下命令来填充配置表:

php artisan webchat:settings

这将为每个可用的设置加载一行。

配置项仍然可以在添加到父网页的openDialogSettings JavaScript变量中覆盖。

功能

Chat Open 参数

如果托管聊天机器人的页面URL包含查询参数'chat_open=true',则聊天将预先打开。

打开事件回调ID

当聊天窗口打开时,与聊天打开事件一起发送默认的welcome回调ID。可以通过设置托管聊天机器人的页面URL上的'callback_id'查询参数来覆盖它。设置查询参数的值将与聊天打开事件一起发送。然后由用户设置一个处理该回调ID的对话。

评论标签

WebChat小部件可以从中获取符合JSON:API规范的端点的评论。要启用评论,请在openDialogSettings中添加commentsEnabled参数,将其设置为true。您还需要传递有关评论实体名称、作者实体名称和部分实体名称的信息。(如果存在)

示例配置

window.openDialogSettings = {
    url: "{{env('APP_URL')}}",
    user : {
        first_name: 'Jane',
        last_name: 'Smith',
        email: 'jane.smith@opendialog.ai',
        external_id: "{{ auth()->user()->id }}",
    },
    comments: {
        commentsEnabled: true,
        commentsName: 'Comments',
        commentsAxiosConfig: {
            baseURL: 'https:///json/',
            headers: {
                // eslint-disable-next-line no-undef
                Authorization: `Bearer {{ auth()->user()->api_token }}`,
                'Content-Type': 'application/vnd.api+json',
            },
        },
        commentsEntityName: 'comments',
        commentsCreatedFieldName: 'created',
        commentsTextFieldName: 'comment',
        commentsAuthorEntityName: 'people',
        commentsAuthorRelationshipName: 'commentAuthor',
        commentsAuthorIdFieldName: 'id',
        commentsAuthorNameFieldName: 'name',
        commentsSectionEntityName: 'posts',
        commentsSectionRelationshipName: 'post',
        commentsSectionIdFieldName: 'id',
        commentsSectionNameFieldName: 'title',
        commentsSectionPathPattern: 'home\\\/posts\\\/(\\\d*)$',
    },
};