The rt
package was
built to make it easier for our own team to work with RT in an automated
fashion. As a result, most functions in the package have return values
suitable for passing into other functions in the rt
package
or functions from other packages. Notably, functions are pipeable
when possible.
Below are some example workflows you might use this package for.
You can always email your RT installations associated email address to create a ticket but you can also create one programmatically:
rt_ticket_create("General", "[email protected]", "Hey, a quick question...")
You could also create a set of tickets from a database dump of some kind, such as an old ticket tracking system.
First, let’s create some example data to work with:
old_tickets <- data.frame(
queue = "General",
subject = c("I need some help", "about those TPS reports...", "hello!"),
requestor = c("[email protected]", "[email protected]", "[email protected]"),
stringsAsFactors = FALSE
)
With some example data, creating tickets for each of those in on go is only a few lines of code:
lapply(seq_len(nrow(old_tickets)), function (row) {
do.call(rt_ticket_create, as.list(old_tickets[row,]))
})
We can then check our work:
# A tibble: 3 x 2
id Subject
<chr> <chr>
1 1 I need some help
2 2 about those TPS reports...
3 3 hello!
Each ticket has a set of properties associated with it and
rt
makes it quick to update those programmatically.
For example, we write R code to resolve a ticket. For example, say we’re ready to resolve ticket number 6:
What if we wanted to re-assign a set of tickets? We could go
about this the slow way: By looking up ticket IDs in our web browser and
resolving them one by one. Instead, we can make rt
do the
work for us:
Many functions in rt
return values suitable for passing
into other functions, such as with the %>%
operator from
the magrittr
package that’s commonly used in the
tidyverse
. Here’s an example of how this can be used:
Comment and Replying
If you’re already using RT, you’re probably already familiar with commenting and replying to tickets. You’ve also possibly pasted text into your web browser from another source.
rt
can help automate some of this.For example, what if we were calculating some statistics for a ticket and wanted to put that information in the ticket as a comment?
Above, we used the handy
capture.output
function along withpaste
but there are many other ways to get information from R into RT.We can look at the comment we just made like so: