\documentclass[10pt,
	    c, 
% 	    aspectratio=169, 
	    xcolor={table,usenames,dvipsnames},
	    hyperref={pdftex, 
	      bookmarks=true, 
	      colorlinks=true,
	      linkcolor=black,
	      urlcolor=blue,
	      citecolor=black,
	      anchorcolor=blue}]{beamer}

\usetheme{%
cambridge% https://github.com/afs25/CambridgeUK-Beamer
% Warsaw%
}

    


\setbeamertemplate{navigation symbols}{}  % suppress navigation symbols

%%% Standard packages:
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{subfigure}
\usepackage{listings}
\usepackage[UKenglish]{isodate}
\usepackage{array}
\usepackage{savesym}%https://groups.google.com/d/msg/comp.text.tex/LSETDAIaJug/1fgkV2Q2mq0J
\savesymbol{Cross}
\usepackage{bbding}
\restoresymbol{bb}{Cross}
\usepackage{marvosym}
\usepackage{multirow}
\usepackage{fontawesome}

% Setup TikZ

\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzstyle{block}=[draw opacity=0.7,line width=1.4cm]

% Declare logos

\newlength{\logoh} \setlength{\logoh}{0.0333333\paperheight} 
% University logo
\pgfdeclareimage[height=1.5\logoh]{beamerlogocambridge}{theme-staticfiles/cul-logos/Cambridge_University_Libraries_Rev_Col}
% OSC logo
\pgfdeclareimage[height=1.5\logoh]{osclogo}{theme-staticfiles/osc-logos/osc-white}
%% Research Data logo
%\pgfdeclareimage[height=1.5\logoh]{datalogo}{theme-staticfiles/osc-logos/data-white}
% Open Access team logo
\pgfdeclareimage[height=1.5\logoh]{oalogo}{theme-staticfiles/osc-logos/oa-white}
%% Thesis logo
%\pgfdeclareimage[height=1.5\logoh]{thesislogo}{theme-staticfiles/osc-logos/theses-white}
% CC-BY licence
\pgfdeclareimage[height=1\logoh]{licence}{theme-staticfiles/cc-licences/cc-by}


% Choose what logos you want to appear

\setbeamertemplate{logo}{%
      \pgfuseimage{beamerlogocambridge}
      \hfill
      \pgfuseimage{licence}
      \hfill
      \pgfuseimage{osclogo}
%      \pgfuseimage{datalogo}
%      \pgfuseimage{oalogo}
%      \pgfuseimage{thesislogo}
   }

% Author, Title, etc.

\title[Zendesk macros]
{%
%  {\bf Making the most of Zendesk macros}
 {\bf Zendesk macros}
}

\subtitle{A crash course for OSC staff}

\author[André Sartori]
{
André Sartori
}

\institute[OSC]
{Office of Scholarly Communication, University of Cambridge, UK}

\date[]
{CUL IT training room \hfill 27 March 2019}

% The main document

\begin{document}

\definecolor{OAorange}{HTML}{E87722}
\definecolor{ThesesGreen}{HTML}{64A70B}

\newcommand{\userin}[1]{\texttt{#1}}
\newenvironment{userinput}[1]{\begin{quote}\normalfont\ttfamily\setlength{\parskip}{#1}}{\end{quote}}
\newenvironment{macrooutput}[1]{\begin{quote}\setlength{\parskip}{#1}}{\end{quote}}
\newcommand{\outtag}[1]{\textcolor{OAorange}{\userin{\{\{ #1 \}\}}}}
\newcommand{\logictag}[1]{\textcolor{ThesesGreen}{\userin{\{\% #1 \%\}}}}
\newcommand{\exercisesymb}{\HandPencilLeft}
\newcommand{\answersymb}{\faThumbsOUp}
\newcommand{\tipsymb}{\faLightbulbO}
\newcommand*{\thead}[1]{\multicolumn{1}{|c|}{\bfseries #1}}%https://tex.stackexchange.com/a/102970

\begin{frame}
  \titlepage
\end{frame}

\section{Introduction}

\begin{frame}{Contents}

By the end of this course, I hope you will be able to:

\begin{itemize}
    \item Create a new Zendesk macro
	\item Edit a Zendesk macro
	\item Use Liquid Markdown to output ticket variables
	\item Use Liquid Markdown to build logic into your macros
	\item Format the output of your macros using Zendesk markup
    \end{itemize}
\end{frame}



\begin{frame}{Symbols and typographic conventions}

The following symbols and typographic conventions are used in these slides:

\begin{itemize}
    \item Emphasis: This is an important \alert{concept} or \alert{keyword}
	\item External links: \url{https://camacuk.zendesk.com} or \href{https://camacuk.zendesk.com}{Zendesk}
	\item User input: \userin{This is something you should type.}
	\item Macro output: \begin{macrooutput}{0em}Your macro printed this.\end{macrooutput}
    \item Liquid output tags: \outtag{ticket.requester}
    \item Liquid logic tags: \logictag{if this is true}
	\item Exercises: \exercisesymb\ in the top right corner of the slide
	\item Exercise solutions: \answersymb\ in the top right corner of the slide
	\item Tips: \tipsymb\ denotes a tip
    \end{itemize}
\end{frame}




\section{Creating and editing macros}

%\subsection{}

\begin{frame}{
Let's \textbf{create} a Zendesk macro! \hfill \exercisesymb}

\begin{itemize}
	\item Log into Zendesk: \url{https://camacuk.zendesk.com/agent}
	\item Click the \alert{Admin} icon (\includegraphics[scale=0.7]{manage-icon}) in the sidebar, then select \alert{Macros}
	\item Click the \alert{Add macro} button
	\item Enter the macro name: \userin{\alert{Salute world}}
	\item Click the \alert{Available for} drop-down menu and select \alert{Me only}
	\item Click \alert{Add action} and choose the \alert{Comment/description} option in the drop-down menu
	\item Enter the text of the macro: \userin{\alert{Hello world!}}
	\item Click \alert{Create} to save your brand new macro
    \end{itemize}
\end{frame}

\begin{frame}{Let's \textbf{test} your new macro! \hfill \exercisesymb}
  \begin{itemize}
	%\item Click the \alert{+ Add} button in the top bar
	\item Navigate to \url{https://camacuk.zendesk.com/agent/tickets/94292}
	\item Click the \alert{\Lightning\ Apply macro} drop-down menu in the bottom bar and type the words "Salute world"
	\item Hit the Enter/Return key on your keyboard
	\item Apply the macro again. What happens?
    \end{itemize}
    
  \begin{block}{Expected output}
  Zendesk adds the string "Hello world!" to the ticket body every time you activate your macro using the steps above.
  \end{block}
\end{frame}



\begin{frame}{Let's \textbf{edit} that macro! \hfill \exercisesymb}

  \begin{itemize}
	\item Click the \alert{Admin} icon (\includegraphics[scale=0.7]{manage-icon}) in the sidebar, then select \alert{Macros}
	\item Change the value of the filter \alert{All shared macros} to \alert{Personal macros}
	\item Click the \alert{Salute world} macro
	\item Change the text produced by the macro to:\vspace{0.2em}
	\begin{userinput}{0.2em}
	  Dear world,
	
	  Please upload your paper via your Elements profile.
	
	  Yours,
	
	  Cambridge
	\end{userinput}
    \end{itemize}
\end{frame}



\begin{frame}{\tipsymb\ Editing a macro you have just used \hfill \exercisesymb}
\begin{block}{Use your macro on a test ticket}
  \begin{itemize}
	\item Go to https://camacuk.zendesk.com/agent/tickets/94292
	\item Apply your \alert{Salute world} macro
	\item Change your reply to \alert{Internal note} and click \alert{Submit as On-hold}
  \end{itemize}	
\end{block}

\begin{block}{Quickly access the macro editing form via ticket Events}
	\begin{itemize}
	\item Change the ticket view from \alert{Conversations} to \alert{Events}
	\item Look for event: \textbf{Macro applied} \alert{Salute world}
	\item Click the link on that event. It will take you to this macro's edit form
	\end{itemize}	
\end{block}
\end{frame}


\section{Actions and introduction to Liquid}


%\begin{frame}{That was sort of fun, but is that all macros can do?}
\begin{frame}{Zendesk macros can do a lot more than that! \hfill \exercisesymb}
\framesubtitle<presentation>{Actions}

%Fortunately not! They can do a lot more. 
Navigate to the macro edit form again and check out the list of available actions. Commonly used options include:  %By using a markup language called Liquid, you can do a lot more with Zendesk macros:
{\small
  \begin{itemize}
	\item \alert{Set subject}: Sets or changes the subject line of the ticket
	\item \alert{Status}: Sets or changes the status (Open, Pending, etc) of the ticket
	\item \alert{Assignee}: Sets or changes the ticket assignee (e.g.\ to \alert{current user})
	\item \alert{Comment mode}: e-mail to requester (\alert{Public}) or internal note (\alert{Private})
	\item Custom ticket fields: Sets or changes the value of ticket fields
    \end{itemize}
}

You can add as many actions to a macro as necessary. All will be performed, each in the order they were added.
\end{frame}


\begin{frame}{Zendesk macros can do a lot more than that!}
\framesubtitle<presentation>{Liquid markup}

Macro e-mails support dynamic content via \href{https://github.com/Shopify/liquid/wiki/Liquid-for-Designers}{Liquid}, a templating language consisting of two types of markup:
\begin{itemize}
 \item \alert{Output markup} is surrounded by
 \begin{center}
  \outtag{matched pairs of curly brackets}
 \end{center}
 When the macro is run, this gets replaced by the value of the expression between the braces. For instance, \userin{\{\{ticket.id\}\}} gets replaced by the ticket number and \userin{\{\{ticket.requester.email\}\}} by the e-mail address of the ticket requester.

 \item \alert{Tag markup} is surrounded by
 \begin{center}
  \logictag{matched pairs of curly brackets and percent signs}
 \end{center}
 Tags cannot resolve to text. They are used for the \alert{logic} of your macro.
\end{itemize}

\end{frame}
% Template e-mails can also be used for much more than just printing static messages. By using a markup language called Liquid, you can instruct your macro's comment/description (i.e.\ the e-mail body) to:
% 
% % https://support.zendesk.com/hc/en-us/articles/203662146-Understanding-Liquid-markup-and-Zendesk-Support
% 
% 
% \begin{itemize}
%   \item Apply different formatting to parts of the message
%   \item Print the value of any ticket field
%   \item Print different outputs conditionally (i.e.\ depending on the value of ticket fields)
% \end{itemize}
% 
% %Let's work through a practical example of how to do each of these.


\section{Liquid output tags}

\begin{frame}{Let's make your macro more general! \hfill \exercisesymb}
\framesubtitle<presentation>{Replacing static text by variables}

Edit your macro so that:
\begin{enumerate}
 \item The e-mail is addressed to the ticket requester rather than to ``world''
 \item It is signed by whoever has activated the macro, rather than by ``Cambridge''
\end{enumerate}

\begin{block}{Tip \hfill \tipsymb}
 Click \alert{View available placeholders} just below the box containing the macro text in the edit form to 
 see a list of supported output markup statements
\end{block}

\end{frame}



\begin{frame}{Here is a possible solution \hfill \answersymb}
 
 \begin{userinput}{1em}
 Dear \outtag{ticket.requester.name},
	
	  Please upload your paper via your Elements profile.
	
	  Yours,
	
	  \outtag{current\_user.first\_name}
 \end{userinput}

\end{frame}



\begin{frame}{Outputing the value of custom ticket fields}

\begin{block}{Definition}
Custom fields are all ticket fields that were created by our team rather than shipped with Zendesk (e.g. \alert{\#Journal title})
% (the latter are termed \alert{system fields} by Zendesk):
% \begin{itemize}
%     \item \alert{\#Journal title} is a custom ticket field
%     \item \alert{Tags} is a system field
% \end{itemize}    
\end{block}

\begin{block}{Syntax}
Use the following syntax to output the value of a custom ticket field:
\begin{center}
    \userin{\outtag{ticket.ticket\_field\_\alert{ID}}}
\end{center}
Where \alert{ID} is a unique numeric identifier of the field of interest.    
\end{block}

\begin{block}{List of ticket field IDs \hfill \tipsymb}
You can find out the \alert{ID} of all ticket fields at \url{https://camacuk.zendesk.com/agent/admin/ticket_fields}    
\end{block}
\end{frame}


\begin{frame}{Edit your macro to output the publication title \hfill \exercisesymb}
\setlength{\parskip}{0.5em} 

    
    After using your macro for one week, you received three replies asking you what paper you are talking about. You decided it would be a good idea to output the title of the paper near the top of your message: 
    
    \begin{macrooutput}{0.5em}
        Dear Dr Sartori,
    
    \alert{Article title: Zendesk macros are useful}
    
    Please upload your paper via your Elements profile.
	
    Yours,
    
    André
    \end{macrooutput}

    
Edit your macro to output the value of ticket field \alert{\#Manuscript title}, matching the highlighted line of the example above.

\end{frame}



\begin{frame}{Here is the solution \hfill \answersymb}
 
 \begin{userinput}{1em}
 Dear \outtag{ticket.requester.name},
 
 Article title: \outtag{ticket.ticket\_field\_24069473}
	
	  Please upload your paper via your Elements profile.
	
	  Yours,
	
	  \outtag{current\_user.first\_name}
 \end{userinput}

\end{frame}


\section{Liquid markup tags (logic)}

\begin{frame}{Building logic into your macros}
\framesubtitle{Conditional statements}

You can also instruct your macro to only produce output if a certain condition is met, such as a particular ticket checkbox being ticked or a dropdown menu having a certain value. 

\begin{block}{Syntax}
{\ttfamily\small%
\logictag{if CONDITION}\ldots\logictag{endif}

\logictag{if CONDITION}\ldots\logictag{elsif CONDITION}\ldots\logictag{else}\ldots\logictag{endif}%
}
\vspace{1em}

Where \texttt{CONDITION} is usually a \alert{comparison} between the current value of a ticket field and a constant using the operators:
\vspace{-0.8em}
\begin{multicols}{2}
\begin{list}{}{}
 \item \texttt{\alert{==}} for equality
 \item \texttt{\alert{!=}} for inequality
 \item \texttt{\alert{$<$}}\hspace{0.5ex} for less than
 \item \texttt{\alert{$<$=}} for less than or equality
 \item \texttt{\alert{$>$}\phantom{a}} for greater than
 \item \texttt{\alert{$>$=}} for greater than or equality
\end{list}
\end{multicols}
\end{block}
\end{frame}


\begin{frame}{Building logic into your macros}
\framesubtitle{Conditional statements---Drop-down fields}

When \userin{CONDITION} involves a \alert{drop-down field}, comparisons are made to tags associated with each value. The word \userin{\alert{blank}} is used to denote that the drop-down field has not been populated (null value). 
\vspace{0.5em}

Here is an example using field ``Is there an APC payment?'':
%\begin{block}{Drop-down field example: ``Is there an APC payment?''}

%\small 
\vspace{0.5em}
\begin{userinput}{0em}
  \small
 \textcolor{ForestGreen}{\logictag{if ticket.ticket\_field\_24071633 == `springer\_compact'}}
 
 \hspace{2em}Your paper is covered by Springer Compact.
 
%  \textcolor{ForestGreen}{\logictag{elsif ticket.ticket\_field\_24071633 == `wiley\_dashboard'}}
%  
%  \hspace{2em}Please refer OA charges to the University's WOA account.
 
 \textcolor{ForestGreen}{\logictag{elsif ticket.ticket\_field\_24071633 == `payment\_yes'}}
 
 \hspace{2em}Please request an invoice for OA charges using the billing address below.
 
 \textcolor{ForestGreen}{\logictag{elsif ticket.ticket\_field\_24071633 == blank}}
 
 \textcolor{ForestGreen}{\logictag{else}}
 
 \hspace{2em}There is no need to select a paid-for Open Access option.
 
 \textcolor{ForestGreen}{\logictag{endif}}
\end{userinput}

% \userin{}
% \end{block}
\end{frame}


\begin{frame}{Building logic into your macros}
\framesubtitle{Conditional statements---Checkbox fields}

When \userin{CONDITION} involves a \alert{checkbox field}:
\begin{list}{}{}
 \item \alert{`0'} denotes the checkbox is \alert{not} ticked
 \item \alert{`1'} denotes the checkbox is ticked
\end{list}
\vspace{0.5em}

Here is an example using field ``RCUK policy'':

\vspace{0.5em}
\begin{userinput}{0em}
  \small
 \textcolor{ForestGreen}{\logictag{if ticket.ticket\_field\_24071783 == `1'}}
 
 \hspace{2em}Your paper is covered by the RCUK Open Access policy.
 
 \textcolor{ForestGreen}{\logictag{endif}}
\end{userinput}

% \userin{}
% \end{block}
\end{frame}


\begin{frame}{Building logic into your macros}
\framesubtitle{Conditional statements---Date fields}

When \userin{CONDITION} involves a \alert{date field}, the date you will compare the value of the field to should be written 
%as a string 
in the format `YYYY-MM-DD'

\vspace{0.5em}

Here is an example using field ``\#Acceptance date'':

\vspace{0.5em}
\begin{userinput}{0em}
  \small
 \textcolor{ForestGreen}{\logictag{if ticket.ticket\_field\_24114776 >= `2016-04-01'}}
 
 \hspace{2em}Your paper is covered by the REF Open Access policy.
 
 \textcolor{ForestGreen}{\logictag{elsif ticket.ticket\_field\_24114776 == blank}}
 
 \hspace{2em}Please send us the acceptance date of your paper.
 
 \textcolor{ForestGreen}{\logictag{endif}}
 
 
\end{userinput}

% \userin{}
% \end{block}
\end{frame}


\begin{frame}{Building logic into your macros}
\framesubtitle{Combining conditional statements}
\small
It is possible to write a \userin{CONDITION} that involves more than one test by using the operators:
\begin{list}{}{}
\item \alert{and} when you want to produce output only when \alert{all} tests succeed
\item \alert{or} \hspace{1.5ex}if you want to produce output when \alert{at least one} test succeed
\end{list}

% \userin{}
% \end{block}
\end{frame}


\begin{frame}{Building logic into your macros}
\framesubtitle{Combining conditional statements---Examples}
\small

Here is an example using the operator \alert{or} to test for two different values of field ``Is there an APC payment?'':

\vspace{0.5em}
\begin{userinput}{0em}
  \small
 \logictag{if ticket.ticket\_field\_24071633 == `springer\_compact' or ticket.ticket\_field\_24071633 == `payment\_yes'}
 
 \hspace{2em}We will be able to cover Open Access charges for your paper.
 
 \logictag{endif}
\end{userinput}

Here is an example combining fields ``\#Publication date'' and ``\#Online Publication Date'' with the operator \alert{and}:

\vspace{0.5em}
\begin{userinput}{0em}
  \small
 \logictag{if ticket.ticket\_field\_24069583 == blank and ticket.ticket\_field\_47509168 == blank}
 
 \hspace{2em}Your paper is under an indefinite embargo as it has not been published yet.
 
 \logictag{endif}
\end{userinput}

% \userin{}
% \end{block}
\end{frame}


\begin{frame}{Nesting conditional statements \hfill \tipsymb}
It is not possible to combine tests using both operators (\alert{and}, \alert{or}) in the same CONDITION, but you work around that limitation by nesting conditional statements. For example:

\vspace{0.5em}

\begin{userinput}{0ex}
\small
\logictag{if ticket.ticket\_field\_24071633 == `springer\_compact' or ticket.ticket\_field\_24071633 == `payment\_yes'}

\hspace{4ex}\logictag{if ticket.ticket\_field\_24069583 == blank and ticket.ticket\_field\_47509168 == blank}

  \hspace{8ex}We will be able to cover Open Access charges for your paper, which has not been published yet.

\hspace{4ex}\logictag{endif}

\logictag{endif}

\end{userinput}

\end{frame}


\begin{frame}{Add conditional statements to your macro\hfill \exercisesymb}

Edit your macro so that it outputs:
\vspace{0.5em}
\begin{itemize}
 \item ``Please upload the \alert{accepted} version of your paper...'' if field \alert{Wrong version} is ticked
 \item an extra sentence if field \alert{\#Online Publication Date} has a value: ``Although your paper is already published, please try to resist the urge of sending us the published version.''
 \item ``There is no need to upload your conference abstract to us'' if field \alert{publication type} has value \alert{conference abstract}
 
\end{itemize}

\begin{block}{List of ticket field IDs and tags \hfill \tipsymb}
Remember that you can find out the \alert{ID} and \alert{tags} of all ticket fields at \url{https://camacuk.zendesk.com/agent/admin/ticket_fields}
\end{block}


\end{frame}


\begin{frame}{Here is a possible solution \hfill \answersymb}
 \begin{userinput}{0.8em}
 \small
 Dear \outtag{ticket.requester.name},
 
 Article title: \outtag{ticket.ticket\_field\_24069473}
 
	  \logictag{if ticket.ticket\_field\_80501387 == `conference\_abstract'}There is no need to upload your conference abstract to us.
	  \logictag{else}
	  Please upload \logictag{if ticket.ticket\_field\_24069523 == `1'}the accepted version of\logictag{endif}your paper via your Elements profile. \logictag{if ticket.ticket\_field\_47509168 != blank}Although your paper is already published, please try to resist the urge of sending us the published version.\logictag{endif}\logictag{endif}
	  
	  Yours,
	
	  \outtag{current\_user.first\_name}
 \end{userinput}

\end{frame}

\section{Good practice: commenting, indenting, syntax highlighting}


\begin{frame}{Making your macro easier to understand}
\framesubtitle{Or, how to invest a little of your time now to avoid much pain later}
 
 Let's focus for a moment on the structure of the main paragraph of your macro:
 
 \begin{userinput}{0.8em}
	  \logictag{if ticket.ticket\_field\_80501387 == `conference\_abstract'}\ldots\logictag{else}\ldots\logictag{if ticket.ticket\_field\_24069523 == `1'}\ldots\logictag{endif}\ldots\logictag{if ticket.ticket\_field\_47509168 != blank}\ldots\logictag{endif}\logictag{endif}
 \end{userinput}

 It is hard to visualise the logical structure even when we replace all text with \ldots

\end{frame} 

\begin{frame}{Making your macro easier to understand}
\framesubtitle{Or, how to invest a little of your time now to avoid much pain later}
 
This is much easier to understand:

{\small
\vspace{0.5em}
 
  \logictag{if ticket.ticket\_field\_80501387 == `conference\_abstract'}
  
    \hspace{4ex}\ldots
  
  \logictag{else}
  
    \hspace{4ex}\ldots
    
    \hspace{4ex}\logictag{if ticket.ticket\_field\_24069523 == `1'}
    
      \hspace{8ex}\ldots
      
    \hspace{4ex}\logictag{endif}
    
    \hspace{4ex}\ldots
    
    \hspace{4ex}\logictag{if ticket.ticket\_field\_47509168 != blank}
    
      \hspace{8ex}\ldots
      
    \hspace{4ex}\logictag{endif}
    
  \logictag{endif}}
  
  \vspace{0.5em}
  But\ldots
  
  
\end{frame} 
  
\begin{frame}[fragile]{Making your macro easier to understand}
\framesubtitle{Or, how to invest a little of your time now to avoid much pain later}

\begin{block}{White space and line breaks are interpreted as such:}
\ldots
\begin{verbatim}
    Please upload 
    
        the accepted version of
    
    your paper via your Elements profile. 
\end{verbatim}
\ldots  
\end{block}

\begin{block}{It might be hard to remember what a condition means:}
 \logictag{if ticket.ticket\_field\_24069523 == `1'}
 
 \logictag{if ticket.ticket\_field\_47509168 != blank}
\end{block}
\end{frame}






\begin{frame}{Commenting your macro code}

\alert{Comments} are completely ignored by Zendesk, so they can be used to annotate and/or indent parts of your macro.

\begin{block}{Syntax}
\logictag{comment}\ldots\logictag{endcomment}
\end{block}

\begin{block}{Example}
\begin{userinput}{0.5em}
{\small
\logictag{if ticket.ticket\_field\_24069523 == `1'}\logictag{comment} 
  
  \hspace{4ex}BEGIN: IF `WRONG VERSION' IS TICKED
    
  \hspace{4ex}\logictag{endcomment}the accepted version of\logictag{comment} 
  
  \hspace{4ex}END: IF `WRONG VERSION' IS TICKED
    
\logictag{endcomment}\logictag{endif}
}
\end{userinput}
\end{block}
\end{frame}



\begin{frame}{Your turn \hfill \exercisesymb}

Add comments to your macro to make more explicit what the following if statements are testing for:
\begin{list}{}{}
    \item \logictag{if ticket.ticket\_field\_24069523 == `1'}
    \item \logictag{if ticket.ticket\_field\_47509168 != blank}
\end{list}
\end{frame}


\begin{frame}{Here is a possible solution \hfill \answersymb}

\begin{userinput}{0em}
\footnotesize
\ldots

\logictag{if ticket.ticket\_field\_24069523 == `1'}\logictag{comment}

    \hspace{4ex}BEGIN: IF "WRONG VERSION" IS TICKED
    
    \hspace{4ex}\logictag{endcomment}the accepted version of\logictag{endif}\logictag{comment}
    
    \hspace{4ex}END: IF "WRONG VERSION" IS TICKED
  
\logictag{endcomment}your paper via your Elements profile. \logictag{if ticket.ticket\_field\_47509168 != blank}\logictag{comment}

    \hspace{4ex}BEGIN: IF "\#ONLINE PUBLICATION DATE" IS NOT NULL
    
    \hspace{4ex}\logictag{endcomment}Although your paper is already published, please try to resit the urge of sending us the published versio\logictag{endif}\logictag{comment}
      
    \hspace{4ex}END: IF "\#ONLINE PUBLICATION DATE" IS NOT NULL

\logictag{endcomment}
    
\ldots
\end{userinput}
\end{frame}



\begin{frame}{Syntax highlighting \hfill \tipsymb}

\footnotesize

Here, I have used colours to faciliate the distinction of Liquid statements from regular text. 
You can obtain a similar effect in Notepad$++$ by:

\begin{itemize}
    \footnotesize
    \item Download this file: \url{https://github.com/osc-cam/zendesk/blob/development/macros/notepad\%2B\%2B_liquid_markup.xml}
    \item Open Notepad$++$ and:
    \begin{itemize}
        \footnotesize
        \item Click \alert{Language} in the top menu and select option \alert{Define your language...}
        \item Click the button \alert{Import...} near the top of the ``User Defined Language'' window
        \item Choose the file you downloaded above and click the \alert{Open} button. A popup reading ``Import successful'' should appear
        \item Click the button \alert{Save As...} near the top of the ``User Defined Language'' window and enter a sensible name (Liquid; Zendesk; etc)
    \end{itemize}
\end{itemize}

Now, the next time you click \alert{Language} in the top menu of Notepad$++$, the option to select the language you just defined should appear at the end of the list. Selecting this language will allow you to view Liquid markup syntax in colour.



\end{frame}



\section{Formatting text with Markdown}


\begin{frame}{Formatting your macro's output with Markdown}

You can use the following notation  to format the output of your macro:

%https://en.wikibooks.org/wiki/LaTeX/Tables#Alternate_Row_Colors_in_Tables
\begin{table}[h]
{\scriptsize
% \rowcolors{2}{blue!10}{blue!5}
\begin{tabular}{ |l|>{\userin\bgroup}p{5cm}<{\egroup}|p{3cm}|}
    \hline
    \rowcolor{cyan!35}
    \thead{Formatting}&\thead{User input}&\thead{Macro output}\\ [0.1em] \hline
    Bold&This is how you **bold** text.&This is how you \textbf{bold} text.\\ \hline
    Italics&This is *italicized* text.&This is \textit{italicized} text.\\ \hline
    \multirow{4}{*} {Headings}&\# Level one&{\normalsize\textbf{Level one}}\\
                                      &\#\# Level two&{\small\textbf{Level two}}\\ 
                                      &\#\#\# Level three&{\footnotesize\textbf{Level three}}\\ 
                                      &\ldots and so on up to level six&\\ \hline
    Links&[Display text](http://www.sampleurl.com)&\href{http://www.sampleurl.com}{Display text}\\ \hline
    \multirow{2}{*} {Bulleted lists}&* Bullet one&$\bullet$ Bullet one\\
                                      &* Bullet two&$\bullet$ Bullet two\\ \hline
    \multirow{2}{*} {Numbered lists}&1. Step one&1. Step one\\
                                      &2. Step two&2. Step two\\ \hline
%     \multirow{2}{*} {Nested lists}&* This is the first level of this list&hi\\
%                                       &\hspace{2ex}* To make a second level, add two spaces before the asterisk or number&hi\\ \hline                                      

\end{tabular}
}
\end{table}

\begin{block}{Tip \hfill \tipsymb}
    \small Markdown works not only in macros, but also in all your replies. You can preview your formatting before sending an e-mail by clicking the \alert{Preview} button of a Zendesk ticket.
\end{block}
\end{frame}

\begin{frame}{Prettify your macro! \hfill \exercisesymb}

Use Markdown to prettify your macro in the following way:

\begin{itemize}
    \item Output the string ``Article title" in \textbf{bold}
    \item The string ``Elements profile" should contain a clickable link to \url{https://elements.admin.cam.ac.uk}
\end{itemize}

\end{frame}


\begin{frame}{Here is the solution \hfill \answersymb}
\begin{userinput}{0.8em}
 \small
 Dear \outtag{ticket.requester.name},
 
 \alert{**}Article title\alert{**}: \outtag{ticket.ticket\_field\_24069473}
 
	  \logictag{if ticket.ticket\_field\_80501387 == `conference\_abstract'}There is no need to upload your conference abstract to us.
	  \logictag{else}
	  Please upload \logictag{if ticket.ticket\_field\_24069523 == `1'}the accepted version of\logictag{endif}your paper via your \alert{[}Elements profile\alert{](https://elements.admin.cam.ac.uk)}. \logictag{if ticket.ticket\_field\_47509168 != blank}Although your paper is already published, please try to resist the urge of sending us the published version.\logictag{endif}\logictag{endif}
	  
	  Yours,
	
	  \outtag{current\_user.first\_name}
 \end{userinput}
\end{frame}


\section{Final thoughts}

\begin{frame}{House rules and recommendations}

To wrap up this crash course, let's go through some suggestions of good practice regarding our collection of macros:

\begin{itemize}
    \item Share your macros by setting ``Available for" to ``Agents in group''
    \item Place your macros in a sensible folder by using this syntax to name your macro:\par
    \userin{Folder :: Subfolder :: Macro name}
    \item Do not be afraid to edit shared macros. Remember: \begin{quote}The only way you can avoid mistakes is by not doing anything!\end{quote}
    \item The macro \href{https://github.com/osc-cam/zendesk/blob/development/macros/oa-general-symplectic}{Open access :: General reply} is exceptional in complexity. To edit this macro you will need to use GitHub. See \url{https://help.github.com/en/desktop/getting-started-with-github-desktop} to get started.
    
\end{itemize}


\end{frame}



\begin{frame}{Where to find more information}

This crash course covered only the most frequently used features of Zendesk macros and Liquid. To learn more about the following topics, please refer to these links:

\begin{block}{Liquid}
\url{https://github.com/Shopify/liquid/wiki/Liquid-for-Designers}
\end{block}

\begin{block}{How to format the output text, add external links, etc}
\url{https://support.zendesk.com/hc/en-us/articles/203691016-Formatting-text-with-Markdown}
\end{block}

\end{frame}



\end{document}

