knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of teamr is to provide a wrapper library to send messages to Microsoft Teams through connectors(incoming webhooks)
You can install the released version of teamr from CRAN with:
install.packages("teamr")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("wwwjk366/teamr")
This is a basic example of send a simple titled message to MS Teams:
library(teamr) # initiate new connector card object cc <- connector_card$new(hookurl = "https://outlook.office.com/webhook/3df58884-d979-409c-a50a-6b13e3bfd6cb@d78aee32-8f91-4f9e-90ea-fb72965d9d7c/IncomingWebhook/a9d73932df4f4d20b3dd57ae9b4b96cb/dba232ed-dcf2-4767-a170-a56562ef8a99") # add text cc$text("This is text of main body.") # add title cc$title("This is message title") # add hyperlink button cc$add_link_button("Read more", "https://www.google.com") # change theme color cc$color("#008000") # print out the payload for checking cc$print() # send to Teams cc$send()
# initiate new connector card object cc <- connector_card$new(hookurl = "https://outlook.office.com/webhook/3df58884-d979-409c-a50a-6b13e3bfd6cb@d78aee32-8f91-4f9e-90ea-fb72965d9d7c/IncomingWebhook/a9d73932df4f4d20b3dd57ae9b4b96cb/dba232ed-dcf2-4767-a170-a56562ef8a99") # add text cc$text("This is text of main body.") # add title cc$title("This is message title") # initiate a new section sec <- card_section$new() sec$text(sec_text = "2018-19 Finals MVP") sec$add_fact(fname = "Position", fvalue = "Forward") sec$title(sec_title = "Player Info") sec$activity_image(sec_activitiy_image = "https://d2cwpp38twqe55.cloudfront.net/req/201905091/images/players/leonaka01.jpg") sec$activity_title(sec_activity_title = "Kawhi Leonard") sec$activity_sub_title(sec_activitiy_subtitle = "LA Clippers") sec$activity_text(sec_activitiy_text = "Activity text") cc$add_section(new_section = sec) cc$send()
# create new action card pa <- action_card$new(type = "ActionCard", name = "Add comment") # add default actions to card pa$add_actions() # add text inputs pa$add_text_inputs(id = "comment", title = "Add comment for this task", is_multi_line = TRUE) # save to the card object cc$add_potential_action(pa) pa2 <- action_card$new(type = "ActionCard", name = "Add Date") pa2$add_actions() pa2$add_date_inputs(id = "date", title = "Add Date for this task") cc$add_potential_action(pa2) pa3 <- action_card$new(type = "ActionCard", name = "Add Options") pa3$add_actions() # add multiple choices. note that choices must be a nested named list pa3$add_mchoice_inputs(id = "mchoice", title = "Choice one", is_multi_select = TRUE, choices = list( list(display="In Progress", value=1), list(display="Active", value=2), list(display="Close", value=3)) ) cc$add_potential_action(pa3) cc$send()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.