Skip to main content

创建模板

域名

  • https://api.incsapp.com

请求路由

  • /external/templates/rcs

请求方式

  • POST

请求头

  • Content-Type: application/json
  • certification-code: f484bd42-4a0c-39d....

请求参数

请求参数列表

参数名 类型 必填 描述
name string 模板名称。最大长度 25,只能包含字母数字字符和下划线。例如:test_template
type string 模板类型,必须是text,richcard,carousel中的一种,参考:模板类型说明
content object 模板内容,参考:模板内容(content)说明和请求示例

模板类型说明

  • 支持的模板类型(type)包括:
    • 文本消息 (text) - 文本消息模板支持包含建议回复或操作的简单文本消息。文本消息最多可包含 11 个建议项。
    • 独立富卡片 (richcard) - 独立富卡片模板允许包含一张富卡片:图片、GIF 或视频,并附带建议回复和操作。该模板中的富卡片最多可包含 4 个建议项。
    • 富卡片轮播 (carousel) - 富卡片轮播模板支持包含至少两张富卡片的轮播展示,其中每张卡片均带有建议回复和操作。富卡片轮播模板最多允许展示 10 张卡片,且每张卡片最多可包含 4 个建议项。

模板内容(content)说明和请求示例

    1.
  1. 文本消息模板(text)
    • content 参数内容说明:
      参数 类型 必填 描述 备注
      textMessage string 带有自定义变量的模板消息。自定义变量用方括号 [variable_name] 表示。最大长度 2500。 例如:Dear [name], it is time to grab a big deal.
      suggestions array 包含建议相关数据的数组 参考:参考:建议内容(suggestions)说明和示例
    • 请求示例
       {
           "name": "test_template",
           "type": "text",
           "content": {
               "textMessage": "Dear [name], your order [order_id] has been shipped.",
               "suggestions": [
                   {
                       "suggestionType": "reply",
                       "text": "Track Order",
                       "postbackData": "track_order_[order_id]"
                   },
                   {
                       "suggestionType": "url_action",
                       "text": "View Details",
                       "postbackData": "view_details",
                       "url": "https://brand.com/orders/[order_id]"
                   }
               ]
           }
       }
      
    2.
  2. 富媒体卡片独立模板(richcard)
    • content 参数内容说明:
      参数 类型 必填 描述 备注
      richCard object 包含富媒体卡片配置的对象 内容见下述richCard 参数内容说明
    • richCard 参数内容说明:
      参数 类型 必填 描述 备注
      cardOrientation string 卡片方向:VERTICAL 或 HORIZONTAL
      cardHeight string 卡片高度:SHORT 或 MEDIUM(仅当 cardOrientation 为 VERTICAL 时适用)
      title string 卡片标题。最大长度 200。
      description string 卡片描述。最大长度 2000。
      mediaUrl string 媒体文件的公共 URL
      thumbnailUrl string 视频缩略图的公共 URL 当媒体为视频时必填
      suggestions array 建议数组,最多 4 个 参考:参考:建议内容(suggestions)说明和示例
    * 请求示例
      
    ```json
      {
          "name": "promo_richcard_url",
          "type": "richcard",
          "content": {
              "richCard": {
                  "cardOrientation": "VERTICAL",
                  "cardHeight": "MEDIUM",
                  "title": "Special Offer",
                  "description": "Limited time offer!",
                  "mediaUrl": "https://cdn.brand.com/images/promo.jpg",
                  "suggestions": [
                      {
                          "suggestionType": "reply",
                          "text": "Learn More",
                          "postbackData": "learn_more"
                      }
                  ]
              }
          }
      }
      ```
    
    3.
  3. 富媒体卡片轮播模板(carousel)
    • content 参数内容说明:

      参数 类型 必填 描述 备注
      carousel object 轮播配置对象 见下述carousel 参数内容说明
    • carousel 参数内容说明:

      参数 类型 必填 描述 备注
      cardWidth string 卡片宽度:SMALL 或 MEDIUM
      cardHeight string 卡片高度:SHORT 或 MEDIUM
      cards array 卡片数组,最少 2 个,最多 10 个 见下述cards 参数内容说明
    • cards 参数内容说明:

      参数 类型 必填 描述 备注
      title string 卡片标题。最大长度 200。
      description string 卡片描述。最大长度 2000。
      mediaUrl string 媒体 URL
      thumbnailUrl string 缩略图 URL 视频时必填
      suggestions array 建议数组,每个卡片最多 4 个 参考:建议内容(suggestions)说明和示例

    * 请求示例

    ```json
      {
          "name": "product_carousel_url",
          "type": "carousel",
          "content": {
              "carousel": {
                  "cardWidth": "MEDIUM",
                  "cardHeight": "SHORT",
                  "cards": [
                      {
                          "title": "Item 1",
                          "description": "Description for item 1",
                          "mediaUrl": "https://cdn.brand.com/item1.jpg",
                          "suggestions": [
                              {
                                  "suggestionType": "reply",
                                  "text": "Select",
                                  "postbackData": "select_1"
                              }
                          ]
                      },
                      {
                          "title": "Item 2",
                          "description": "Description for item 2",
                          "mediaUrl": "https://cdn.brand.com/item2.jpg",
                          "suggestions": [
                              {
                                  "suggestionType": "reply",
                                  "text": "Select",
                                  "postbackData": "select_2"
                              }
                          ]
                      }
                  ]
              }
          }
      }
      ```
    

建议内容(suggestions)说明和示例

11. URL 动作 - 浏览器

在浏览器中打开 URL。

参数 必填 描述
suggestionType 设置为 "url_action"
url 要打开的有效公共 URL
{
    "suggestionType": "url_action",
    "text": "Visit Website",
    "postbackData": "visit_website",
    "url": "https://brand.com"
}
22. 拨号动作

拨打电话号码。

参数 必填 描述
suggestionType 设置为 "dialer_action"
phoneNumber 国际格式的有效电话号码
{
    "suggestionType": "dialer_action",
    "text": "Call Us",
    "postbackData": "call_support",
    "phoneNumber": "+6281234567890"
}
33. 查看位置

在地图中显示特定位置。

参数 必填 描述
suggestionType 设置为 "view_location"
latitude 纬度
longitude 经度
label 位置标签
{
    "suggestionType": "view_location",
    "text": "View Store",
    "postbackData": "view_store_location",
    "latitude": -6.2088,
    "longitude": 106.8456,
    "label": "Brand Store Jakarta"
}
44. 查询位置

搜索附近的位置。

参数 必填 描述
suggestionType 设置为 "query_location"
query 搜索查询字符串
{
    "suggestionType": "query_location",
    "text": "Find Nearby",
    "postbackData": "find_nearby_stores",
    "query": "Brand Store near me"
}
55. 分享位置

请求用户分享其当前位置。

{
    "suggestionType": "share_location",
    "text": "Share Location",
    "postbackData": "user_shared_location"
}
66. 日历事件

在用户日历中创建事件。

参数 必填 描述
suggestionType 设置为 "calendar_event"
title 事件标题
description 事件描述
startTime 开始时间(ISO 8601 格式)
endTime 结束时间(ISO 8601 格式)
{
    "suggestionType": "calendar_event",
    "text": "Add to Calendar",
    "postbackData": "add_event",
    "title": "Product Launch Event",
    "description": "Join us for the exciting product launch",
    "startTime": "2024-05-01T10:00:00+07:00",
    "endTime": "2024-05-01T12:00:00+07:00"
}
77. URL 动作 - WebView

在应用内 WebView 中打开 URL。

参数 必填 描述
suggestionType 设置为 "webview_action"
url 要在 WebView 中打开的 URL
viewMode 视图模式:FULL、HALF、TALL
description WebView 的可访问性描述
{
    "suggestionType": "webview_action",
    "text": "Open Form",
    "postbackData": "open_webview_form",
    "url": "https://brand.com/form",
    "viewMode": "FULL",
    "description": "Registration form"
}

响应

成功响应示例

{
    "status": "success",
    "code": 200,
    "message": "",
    "data": {
        "template_id": "2217676094281515152",
        "name": "api_5_text",
        "type": "text",
        "status": "PENDING",
        "content": {
            "textMessage": "Dear [name], time to use rcs api",
            "suggestions": [
                {
                    "suggestionType": "reply",
                    "text": "Join us",
                    "postbackData": "click_reply"
                }
            ]
        },
        "created_time": 1767609428,
        "updated_time": 1767609428,
        "status_updated_time": 0
    },
    "error": {}
}

失败响应示例

{
    "status": "error",
    "code": 400,
    "message": "type require",
    "data": {},
    "error": {}
}