README.md

slackblocks

Lifecycle:
experimental Covrpage
Summary R-CMD-check Codecov test
coverage

slackblocks is a part of slackverse

| | | | | :-----------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------: | | | slackcalls | | | slackthreads | slackteams | slackposts | | | | slackblocks | | | | slackreprex |

The goal of slackblocks is to build Slack block elements in R.

Installation

# install.packages("remotes")
remotes::install_github("yonicd/slackblocks")

Example

This is a basic example which shows you how to solve a common problem:

library(slackblocks)
block_text('my text')
#> {
#>   "type": "mrkdwn",
#>   "text": "my text"
#> }
image_element('url_to_image')
#> {
#>   "type": "image",
#>   "image_url": "url_to_image",
#>   "alt_text": "image"
#> }
(b <- section_block(
  text = block_text(
    text = 'A message *with some bold text* and _some italicized text_.'),
  fields = list(
    block_text('*Priority*'),
    block_text('*Type*'),
    block_text('High'),
    block_text(':heavy_check_mark:')
    )
  ))
#> {
#>   "type": "section",
#>   "text": {
#>     "type": "mrkdwn",
#>     "text": "A message *with some bold text* and _some italicized text_."
#>   },
#>   "fields": [
#>     {
#>       "type": "mrkdwn",
#>       "text": "*Priority*"
#>     },
#>     {
#>       "type": "mrkdwn",
#>       "text": "*Type*"
#>     },
#>     {
#>       "type": "mrkdwn",
#>       "text": "High"
#>     },
#>     {
#>       "type": "mrkdwn",
#>       "text": ":heavy_check_mark:"
#>     }
#>   ]
#> }

Posting Blocks to Slack

post_block(b, channel = 'CHANNELID')



yonicd/slackblocks documentation built on March 2, 2023, 6:53 a.m.