Open Context Protocol is live! 🚀 Read the launch post

chatPostMessage

Sends a message to a channel.

Details

  • Method: POST
  • Path: /chat.postMessage
  • Operation ID: chat_postMessage

Parameters

{
  "token": {
    "description": "Authentication token. Requires scope: `chat:write`",
    "required": true,
    "location": "header",
    "type": "string"
  },
  "as_user": {
    "description": "Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See [authorship](#authorship) below.",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "attachments": {
    "description": "A JSON-based array of structured attachments, presented as a URL-encoded string.",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "blocks": {
    "description": "A JSON-based array of structured blocks, presented as a URL-encoded string.",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "channel": {
    "description": "Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See [below](#channels) for more details.",
    "required": true,
    "location": "formData",
    "type": "string"
  },
  "icon_emoji": {
    "description": "Emoji to use as the icon for this message. Overrides `icon_url`. Must be used in conjunction with `as_user` set to `false`, otherwise ignored. See [authorship](#authorship) below.",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "icon_url": {
    "description": "URL to an image to use as the icon for this message. Must be used in conjunction with `as_user` set to false, otherwise ignored. See [authorship](#authorship) below.",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "link_names": {
    "description": "Find and link channel names and usernames.",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "mrkdwn": {
    "description": "Disable Slack markup parsing by setting to `false`. Enabled by default.",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "parse": {
    "description": "Change how messages are treated. Defaults to `none`. See [below](#formatting).",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "reply_broadcast": {
    "description": "Used in conjunction with `thread_ts` and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to `false`.",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "text": {
    "description": "How this field works and whether it is required depends on other fields you use in your API call. [See below](#text_usage) for more detail.",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "thread_ts": {
    "description": "Provide another message's `ts` value to make this message a reply. Avoid using a reply's `ts` value; use its parent instead.",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "unfurl_links": {
    "description": "Pass true to enable unfurling of primarily text-based content.",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "unfurl_media": {
    "description": "Pass false to disable unfurling of media content.",
    "required": false,
    "location": "formData",
    "type": "string"
  },
  "username": {
    "description": "Set your bot's user name. Must be used in conjunction with `as_user` set to false, otherwise ignored. See [authorship](#authorship) below.",
    "required": false,
    "location": "formData",
    "type": "string"
  }
}

Response Schema

{
  "additionalProperties": false,
  "description": "Schema for successful response of chat.postMessage method",
  "properties": {
    "channel": {
      "pattern": "^[CGD][A-Z0-9]{8,}$",
      "title": "Channel-like conversation ID",
      "type": "string"
    },
    "message": {
      "additionalProperties": false,
      "properties": {
        "attachments": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "fallback": {
                "type": "string"
              },
              "id": {
                "type": "integer"
              },
              "image_bytes": {
                "type": "integer"
              },
              "image_height": {
                "type": "integer"
              },
              "image_url": {
                "type": "string"
              },
              "image_width": {
                "type": "integer"
              }
            },
            "required": [
              "id"
            ],
            "type": "object"
          },
          "minItems": 1,
          "type": "array",
          "uniqueItems": true
        },
        "blocks": {
          "description": "This is a very loose definition, in the future, we'll populate this with deeper schema in this definition namespace.",
          "items": {
            "additionalProperties": true,
            "properties": {
              "type": {
                "type": "string"
              }
            },
            "required": [
              "type"
            ],
            "type": "object"
          },
          "title": "Block Kit blocks",
          "type": "array"
        },
        "bot_id": {
          "items": [
            {
              "pattern": "^B[A-Z0-9]{8,}$",
              "title": "Bot User ID",
              "type": "string"
            },
            {
              "title": "Nil bot_id set when display_as_bot is false",
              "type": "null"
            }
          ]
        },
        "bot_profile": {
          "additionalProperties": false,
          "properties": {
            "app_id": {
              "pattern": "^A[A-Z0-9]{1,}$",
              "title": "App ID",
              "type": "string"
            },
            "deleted": {
              "type": "boolean"
            },
            "icons": {
              "additionalProperties": false,
              "properties": {
                "image_36": {
                  "format": "uri",
                  "type": "string"
                },
                "image_48": {
                  "format": "uri",
                  "type": "string"
                },
                "image_72": {
                  "format": "uri",
                  "type": "string"
                }
              },
              "required": [
                "image_36",
                "image_48",
                "image_72"
              ],
              "type": "object"
            },
            "id": {
              "pattern": "^B[A-Z0-9]{8,}$",
              "title": "Bot User ID",
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "team_id": {
              "pattern": "^[T][A-Z0-9]{2,}$",
              "title": "Team ID",
              "type": "string"
            },
            "updated": {
              "type": "integer"
            }
          },
          "required": [
            "id",
            "deleted",
            "name",
            "updated",
            "app_id",
            "icons",
            "team_id"
          ],
          "title": "Bot Profile Object",
          "type": "object"
        },
        "client_msg_id": {
          "type": "string"
        },
        "comment": {
          "additionalProperties": false,
          "properties": {
            "comment": {
              "type": "string"
            },
            "created": {
              "type": "integer"
            },
            "id": {
              "pattern": "^Fc[A-Z0-9]{8,}$",
              "title": "File Comment ID",
              "type": "string"
            },
            "is_intro": {
              "type": "boolean"
            },
            "is_starred": {
              "type": "boolean"
            },
            "num_stars": {
              "type": "integer"
            },
            "pinned_info": {
              "additionalProperties": false,
              "title": "Info for a pinned item",
              "type": "object"
            },
            "pinned_to": {
              "items": {
                "pattern": "^[CGD][A-Z0-9]{8,}$",
                "title": "Channel-like conversation ID",
                "type": "string"
              },
              "type": "array"
            },
            "reactions": {
              "items": {
                "additionalProperties": true,
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "name": {
                    "type": "string"
                  },
                  "users": {
                    "items": {
                      "pattern": "^[UW][A-Z0-9]{2,}$",
                      "title": "User ID",
                      "type": "string"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "name",
                  "users",
                  "count"
                ],
                "title": "Reaction object",
                "type": "object"
              },
              "type": "array"
            },
            "timestamp": {
              "type": "integer"
            },
            "user": {
              "pattern": "^[UW][A-Z0-9]{2,}$",
              "title": "User ID",
              "type": "string"
            }
          },
          "required": [
            "id",
            "created",
            "timestamp",
            "user",
            "is_intro",
            "comment"
          ],
          "title": "File Comment Object",
          "type": "object"
        },
        "display_as_bot": {
          "type": "boolean"
        },
        "file": {
          "additionalProperties": false,
          "properties": {
            "channels": {
              "items": {
                "pattern": "^[C][A-Z0-9]{2,}$",
                "title": "Channel ID",
                "type": "string"
              },
              "type": "array",
              "uniqueItems": true
            },
            "comments_count": {
              "type": "integer"
            },
            "created": {
              "type": "integer"
            },
            "date_delete": {
              "type": "integer"
            },
            "display_as_bot": {
              "type": "boolean"
            },
            "editable": {
              "type": "boolean"
            },
            "editor": {
              "pattern": "^[UW][A-Z0-9]{2,}$",
              "title": "User ID",
              "type": "string"
            },
            "external_id": {
              "type": "string"
            },
            "external_type": {
              "type": "string"
            },
            "external_url": {
              "format": "uri",
              "type": "string"
            },
            "filetype": {
              "type": "string"
            },
            "groups": {
              "items": {
                "pattern": "^[G][A-Z0-9]{8,}$",
                "title": "Private Channel ID",
                "type": "string"
              },
              "type": "array",
              "uniqueItems": true
            },
            "has_rich_preview": {
              "type": "boolean"
            },
            "id": {
              "pattern": "^[F][A-Z0-9]{8,}$",
              "title": "File ID",
              "type": "string"
            },
            "image_exif_rotation": {
              "type": "integer"
            },
            "ims": {
              "items": {
                "pattern": "^[D][A-Z0-9]{8,}$",
                "title": "Direct Message Channel ID",
                "type": "string"
              },
              "type": "array",
              "uniqueItems": true
            },
            "is_external": {
              "type": "boolean"
            },
            "is_public": {
              "type": "boolean"
            },
            "is_starred": {
              "type": "boolean"
            },
            "is_tombstoned": {
              "type": "boolean"
            },
            "last_editor": {
              "pattern": "^[UW][A-Z0-9]{2,}$",
              "title": "User ID",
              "type": "string"
            },
            "mimetype": {
              "type": "string"
            },
            "mode": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "non_owner_editable": {
              "type": "boolean"
            },
            "num_stars": {
              "type": "integer"
            },
            "original_h": {
              "type": "integer"
            },
            "original_w": {
              "type": "integer"
            },
            "permalink": {
              "format": "uri",
              "type": "string"
            },
            "permalink_public": {
              "format": "uri",
              "type": "string"
            },
            "pinned_info": {
              "additionalProperties": false,
              "title": "Info for a pinned item",
              "type": "object"
            },
            "pinned_to": {
              "items": {
                "pattern": "^[CGD][A-Z0-9]{8,}$",
                "title": "Channel-like conversation ID",
                "type": "string"
              },
              "type": "array"
            },
            "pretty_type": {
              "type": "string"
            },
            "preview": {
              "type": "string"
            },
            "public_url_shared": {
              "type": "boolean"
            },
            "reactions": {
              "items": {
                "additionalProperties": true,
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "name": {
                    "type": "string"
                  },
                  "users": {
                    "items": {
                      "pattern": "^[UW][A-Z0-9]{2,}$",
                      "title": "User ID",
                      "type": "string"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "name",
                  "users",
                  "count"
                ],
                "title": "Reaction object",
                "type": "object"
              },
              "type": "array"
            },
            "shares": {
              "additionalProperties": false,
              "properties": {
                "private": {
                  "additionalProperties": false
                },
                "public": {
                  "additionalProperties": false
                }
              },
              "type": "object"
            },
            "size": {
              "type": "integer"
            },
            "source_team": {
              "pattern": "^[T][A-Z0-9]{2,}$",
              "title": "Team ID",
              "type": "string"
            },
            "state": {
              "type": "string"
            },
            "thumb_1024": {
              "format": "uri",
              "type": "string"
            },
            "thumb_1024_h": {
              "type": "integer"
            },
            "thumb_1024_w": {
              "type": "integer"
            },
            "thumb_160": {
              "format": "uri",
              "type": "string"
            },
            "thumb_360": {
              "format": "uri",
              "type": "string"
            },
            "thumb_360_h": {
              "type": "integer"
            },
            "thumb_360_w": {
              "type": "integer"
            },
            "thumb_480": {
              "format": "uri",
              "type": "string"
            },
            "thumb_480_h": {
              "type": "integer"
            },
            "thumb_480_w": {
              "type": "integer"
            },
            "thumb_64": {
              "format": "uri",
              "type": "string"
            },
            "thumb_720": {
              "format": "uri",
              "type": "string"
            },
            "thumb_720_h": {
              "type": "integer"
            },
            "thumb_720_w": {
              "type": "integer"
            },
            "thumb_80": {
              "format": "uri",
              "type": "string"
            },
            "thumb_800": {
              "format": "uri",
              "type": "string"
            },
            "thumb_800_h": {
              "type": "integer"
            },
            "thumb_800_w": {
              "type": "integer"
            },
            "thumb_960": {
              "format": "uri",
              "type": "string"
            },
            "thumb_960_h": {
              "type": "integer"
            },
            "thumb_960_w": {
              "type": "integer"
            },
            "thumb_tiny": {
              "type": "string"
            },
            "timestamp": {
              "type": "integer"
            },
            "title": {
              "type": "string"
            },
            "updated": {
              "type": "integer"
            },
            "url_private": {
              "format": "uri",
              "type": "string"
            },
            "url_private_download": {
              "format": "uri",
              "type": "string"
            },
            "user": {
              "type": "string"
            },
            "user_team": {
              "pattern": "^[T][A-Z0-9]{2,}$",
              "title": "Team ID",
              "type": "string"
            },
            "username": {
              "type": "string"
            }
          },
          "title": "file object",
          "type": "object"
        },
        "files": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "channels": {
                "items": {
                  "pattern": "^[C][A-Z0-9]{2,}$",
                  "title": "Channel ID",
                  "type": "string"
                },
                "type": "array",
                "uniqueItems": true
              },
              "comments_count": {
                "type": "integer"
              },
              "created": {
                "type": "integer"
              },
              "date_delete": {
                "type": "integer"
              },
              "display_as_bot": {
                "type": "boolean"
              },
              "editable": {
                "type": "boolean"
              },
              "editor": {
                "pattern": "^[UW][A-Z0-9]{2,}$",
                "title": "User ID",
                "type": "string"
              },
              "external_id": {
                "type": "string"
              },
              "external_type": {
                "type": "string"
              },
              "external_url": {
                "format": "uri",
                "type": "string"
              },
              "filetype": {
                "type": "string"
              },
              "groups": {
                "items": {
                  "pattern": "^[G][A-Z0-9]{8,}$",
                  "title": "Private Channel ID",
                  "type": "string"
                },
                "type": "array",
                "uniqueItems": true
              },
              "has_rich_preview": {
                "type": "boolean"
              },
              "id": {
                "pattern": "^[F][A-Z0-9]{8,}$",
                "title": "File ID",
                "type": "string"
              },
              "image_exif_rotation": {
                "type": "integer"
              },
              "ims": {
                "items": {
                  "pattern": "^[D][A-Z0-9]{8,}$",
                  "title": "Direct Message Channel ID",
                  "type": "string"
                },
                "type": "array",
                "uniqueItems": true
              },
              "is_external": {
                "type": "boolean"
              },
              "is_public": {
                "type": "boolean"
              },
              "is_starred": {
                "type": "boolean"
              },
              "is_tombstoned": {
                "type": "boolean"
              },
              "last_editor": {
                "pattern": "^[UW][A-Z0-9]{2,}$",
                "title": "User ID",
                "type": "string"
              },
              "mimetype": {
                "type": "string"
              },
              "mode": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "non_owner_editable": {
                "type": "boolean"
              },
              "num_stars": {
                "type": "integer"
              },
              "original_h": {
                "type": "integer"
              },
              "original_w": {
                "type": "integer"
              },
              "permalink": {
                "format": "uri",
                "type": "string"
              },
              "permalink_public": {
                "format": "uri",
                "type": "string"
              },
              "pinned_info": {
                "additionalProperties": false,
                "title": "Info for a pinned item",
                "type": "object"
              },
              "pinned_to": {
                "items": {
                  "pattern": "^[CGD][A-Z0-9]{8,}$",
                  "title": "Channel-like conversation ID",
                  "type": "string"
                },
                "type": "array"
              },
              "pretty_type": {
                "type": "string"
              },
              "preview": {
                "type": "string"
              },
              "public_url_shared": {
                "type": "boolean"
              },
              "reactions": {
                "items": {
                  "additionalProperties": true,
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "name": {
                      "type": "string"
                    },
                    "users": {
                      "items": {
                        "pattern": "^[UW][A-Z0-9]{2,}$",
                        "title": "User ID",
                        "type": "string"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "name",
                    "users",
                    "count"
                  ],
                  "title": "Reaction object",
                  "type": "object"
                },
                "type": "array"
              },
              "shares": {
                "additionalProperties": false,
                "properties": {
                  "private": {
                    "additionalProperties": false
                  },
                  "public": {
                    "additionalProperties": false
                  }
                },
                "type": "object"
              },
              "size": {
                "type": "integer"
              },
              "source_team": {
                "pattern": "^[T][A-Z0-9]{2,}$",
                "title": "Team ID",
                "type": "string"
              },
              "state": {
                "type": "string"
              },
              "thumb_1024": {
                "format": "uri",
                "type": "string"
              },
              "thumb_1024_h": {
                "type": "integer"
              },
              "thumb_1024_w": {
                "type": "integer"
              },
              "thumb_160": {
                "format": "uri",
                "type": "string"
              },
              "thumb_360": {
                "format": "uri",
                "type": "string"
              },
              "thumb_360_h": {
                "type": "integer"
              },
              "thumb_360_w": {
                "type": "integer"
              },
              "thumb_480": {
                "format": "uri",
                "type": "string"
              },
              "thumb_480_h": {
                "type": "integer"
              },
              "thumb_480_w": {
                "type": "integer"
              },
              "thumb_64": {
                "format": "uri",
                "type": "string"
              },
              "thumb_720": {
                "format": "uri",
                "type": "string"
              },
              "thumb_720_h": {
                "type": "integer"
              },
              "thumb_720_w": {
                "type": "integer"
              },
              "thumb_80": {
                "format": "uri",
                "type": "string"
              },
              "thumb_800": {
                "format": "uri",
                "type": "string"
              },
              "thumb_800_h": {
                "type": "integer"
              },
              "thumb_800_w": {
                "type": "integer"
              },
              "thumb_960": {
                "format": "uri",
                "type": "string"
              },
              "thumb_960_h": {
                "type": "integer"
              },
              "thumb_960_w": {
                "type": "integer"
              },
              "thumb_tiny": {
                "type": "string"
              },
              "timestamp": {
                "type": "integer"
              },
              "title": {
                "type": "string"
              },
              "updated": {
                "type": "integer"
              },
              "url_private": {
                "format": "uri",
                "type": "string"
              },
              "url_private_download": {
                "format": "uri",
                "type": "string"
              },
              "user": {
                "type": "string"
              },
              "user_team": {
                "pattern": "^[T][A-Z0-9]{2,}$",
                "title": "Team ID",
                "type": "string"
              },
              "username": {
                "type": "string"
              }
            },
            "title": "file object",
            "type": "object"
          },
          "minItems": 1,
          "type": "array",
          "uniqueItems": true
        },
        "icons": {
          "additionalProperties": false,
          "properties": {
            "emoji": {
              "type": "string"
            },
            "image_64": {
              "format": "uri",
              "type": "string"
            }
          },
          "type": "object"
        },
        "inviter": {
          "pattern": "^[UW][A-Z0-9]{2,}$",
          "title": "User ID",
          "type": "string"
        },
        "is_delayed_message": {
          "type": "boolean"
        },
        "is_intro": {
          "type": "boolean"
        },
        "is_starred": {
          "type": "boolean"
        },
        "last_read": {
          "pattern": "^\\d{10}\\.\\d{6}$",
          "title": "Timestamp in format 0123456789.012345",
          "type": "string"
        },
        "latest_reply": {
          "pattern": "^\\d{10}\\.\\d{6}$",
          "title": "Timestamp in format 0123456789.012345",
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "old_name": {
          "type": "string"
        },
        "parent_user_id": {
          "pattern": "^[UW][A-Z0-9]{2,}$",
          "title": "User ID",
          "type": "string"
        },
        "permalink": {
          "format": "uri",
          "type": "string"
        },
        "pinned_to": {
          "items": {
            "pattern": "^[CGD][A-Z0-9]{8,}$",
            "title": "Channel-like conversation ID",
            "type": "string"
          },
          "type": "array"
        },
        "purpose": {
          "type": "string"
        },
        "reactions": {
          "items": {
            "additionalProperties": true,
            "properties": {
              "count": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "users": {
                "items": {
                  "pattern": "^[UW][A-Z0-9]{2,}$",
                  "title": "User ID",
                  "type": "string"
                },
                "type": "array"
              }
            },
            "required": [
              "name",
              "users",
              "count"
            ],
            "title": "Reaction object",
            "type": "object"
          },
          "type": "array"
        },
        "reply_count": {
          "type": "integer"
        },
        "reply_users": {
          "items": {
            "pattern": "^[UW][A-Z0-9]{2,}$",
            "title": "User ID",
            "type": "string"
          },
          "minItems": 1,
          "type": "array",
          "uniqueItems": true
        },
        "reply_users_count": {
          "type": "integer"
        },
        "source_team": {
          "pattern": "^[TE][A-Z0-9]{8,}$",
          "title": "Team or Enterprise ID",
          "type": "string"
        },
        "subscribed": {
          "type": "boolean"
        },
        "subtype": {
          "type": "string"
        },
        "team": {
          "pattern": "^[TE][A-Z0-9]{8,}$",
          "title": "Team or Enterprise ID",
          "type": "string"
        },
        "text": {
          "type": "string"
        },
        "thread_ts": {
          "pattern": "^\\d{10}\\.\\d{6}$",
          "title": "Timestamp in format 0123456789.012345",
          "type": "string"
        },
        "topic": {
          "type": "string"
        },
        "ts": {
          "pattern": "^\\d{10}\\.\\d{6}$",
          "title": "Timestamp in format 0123456789.012345",
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "unread_count": {
          "type": "integer"
        },
        "upload": {
          "type": "boolean"
        },
        "user": {
          "pattern": "^[UW][A-Z0-9]{2,}$",
          "title": "User ID",
          "type": "string"
        },
        "user_profile": {
          "additionalProperties": false,
          "properties": {
            "avatar_hash": {
              "type": "string"
            },
            "display_name": {
              "type": "string"
            },
            "display_name_normalized": {
              "type": "string"
            },
            "first_name": {
              "type": [
                "string",
                "null"
              ]
            },
            "image_72": {
              "format": "uri",
              "type": "string"
            },
            "is_restricted": {
              "type": "boolean"
            },
            "is_ultra_restricted": {
              "type": "boolean"
            },
            "name": {
              "type": "string"
            },
            "real_name": {
              "type": "string"
            },
            "real_name_normalized": {
              "type": "string"
            },
            "team": {
              "pattern": "^[TE][A-Z0-9]{8,}$",
              "title": "Team or Enterprise ID",
              "type": "string"
            }
          },
          "required": [
            "avatar_hash",
            "image_72",
            "first_name",
            "real_name",
            "display_name",
            "team",
            "name",
            "is_restricted",
            "is_ultra_restricted"
          ],
          "type": "object"
        },
        "user_team": {
          "pattern": "^[TE][A-Z0-9]{8,}$",
          "title": "Team or Enterprise ID",
          "type": "string"
        },
        "username": {
          "type": "string"
        }
      },
      "required": [
        "text",
        "type",
        "ts"
      ],
      "title": "Message object",
      "type": "object"
    },
    "ok": {
      "enum": [
        true
      ],
      "title": "default success response",
      "type": "boolean"
    },
    "ts": {
      "pattern": "^\\d{10}\\.\\d{6}$",
      "title": "Timestamp in format 0123456789.012345",
      "type": "string"
    }
  },
  "required": [
    "ok",
    "channel",
    "ts",
    "message"
  ],
  "title": "chat.postMessage success schema",
  "type": "object"
}

Usage

from ocp_agent import OCPAgent

agent = OCPAgent()
await agent.register_api('slack')

# Call this tool
result = await agent.call_tool('chatPostMessage', {
    # Add required parameters here
})