jimstrike / craft-intercom-messenger
Intercom Messenger
Requires
- php: ^8.0.2
- craftcms/cms: ^4.0.0|^5.0.0
This package is auto-updated.
Last update: 2024-09-20 21:27:22 UTC
README
这是Intercom:您和您的客户都将喜爱的企业消息传递工具
概述
是的,它提供了实时聊天功能。但还有机器人、应用程序、产品导览以及其他功能,如电子邮件、消息和帮助中心,这些都有助于您与客户建立关系。
更多信息请访问:Intercom.com。
需求
此插件需要Craft CMS 4.0.0|5.0.0或更高版本。
为了使用此插件,您需要Intercom 试用版或订阅版。或者,您可以在注册订阅之前创建一个免费的开发者账户,以在开发环境中构建和测试Intercom Messenger。
更多信息请访问Intercom.com。
安装
从插件商店
进入项目的控制面板中的插件商店,搜索"Intercom Messenger"。然后点击“安装”按钮。
使用Composer
# Go to project directory cd /path/to/my/craft-project # Tell Composer to load the plugin composer require jimstrike/craft-intercom-messenger # Tell Craft to install the plugin ./craft plugin/install intercom-messenger
设置和自定义您的消息传递器以开始与客户聊天
在Craft控制面板中启用此插件之前,您需要在Intercom上设置和自定义您的消息传递器。
为了满足要求,您需要Intercom 试用版或订阅版才能使用此插件。或者,您可以在注册订阅之前创建一个免费的开发者账户,以在开发环境中构建和测试Intercom Messenger。
以下是一些链接,可以帮助您开始使用Intercom
在您的网站上使用"Intercom Messenger"
在Intercom上设置和自定义消息传递器后,转到Craft控制面板中的“Intercom Messenger”网站设置,按照说明进行操作并启用它。
高级配置
针对Craft开发者
覆盖设置
将插件的src/config.php
复制到您的项目的config
文件夹中,作为intercom-messenger.php
,并在那里进行更改以覆盖默认设置。
在Twig模板中插入Intercom Messenger聊天
{## # @param int|null siteId (defaults to current site ID) # @param bool wrap (whether to wrap with <script>...</script> tag) # # @return string (Intercom Messenger chat script) #} intercom_messenger_script(int siteId = null, bool wrap = false) craft['intercom-messenger'].script(int siteId = null, bool wrap = false)
注意:为了避免代码重复,脚本只有在插件在
Intercom Messenger → 网站设置
或"config/intercom-messenger.php"
文件中禁用时才会插入。
Twig示例
{## # Insert inside twig js tag. #} {% js %} {{ intercom_messenger_script(currentSite.id)|raw }} {#{ craft['intercom-messenger'].script(currentSite.id)|raw }#} {% endjs %} {## # Insert before </body> ending tag. # # Passing the second parameter and setting it to true # will wrap the code with html <script>...</script> tags. #} {{ intercom_messenger_script(currentSite.id, true)|raw }} {#{ craft['intercom-messenger'].script(currentSite.id, true)|raw }#} {## # Insert before </body> ending tag. # # Omit the second parameter or set it to false # and place the code inside html <script>...</script> tags. #} <script> {{ intercom_messenger_script(currentSite.id)|raw }} {#{ craft['intercom-messenger'].script(currentSite.id)|raw }#} </script>
注意:由于您控制自己的Twig模板,因此不会对“启用”、“部分”和“URL路径”进行检查。
自定义启动器
要启用自定义启动器,请将标签属性(见下文)添加到您希望点击时打开 Messanger 的 HTML 元素。您可以根据需要添加任意数量的自定义启动器到您的网站。
您可以选择禁用标准启动器,这样只会显示您的自定义启动器。
{## # Use one of the following twig functions # to generate the tag attribute for the HTML element that you want # the Messenger to open when clicked. #} {{ intercom_messenger_custom_launcher_selector() }} {{ craft['intercom-messenger'].customLauncherSelector() }} {# Example 1 #} <a href="mailto:help@your-app.com" {{ intercom_messenger_custom_launcher_selector() }}>Support</a> {# Example 2 #} <a href="mailto:help@your-app.com" {{ craft['intercom-messenger'].customLauncherSelector() }}>Support</a> {# The above examples will produce something like this #} <a href="mailto:help@your-app.com" ns-intercom-messenger-custom-launcher>Support</a>
注意:在使用此功能之前,您需要在
Intercom Messanger → 网站设置
或"config/intercom-messenger.php" 文件
中启用自定义启动器。
Craft 3
要使用此插件与 Craft 3,您需要从最新的 v1.* 标签版本安装它。查看所有标签。
# Go to project directory cd /path/to/my/craft-project # Tell Composer to load the plugin composer require jimstrike/craft-intercom-messenger:1.0.3 # Tell Craft to install the plugin ./craft plugin/install intercom-messenger