In order to generate an XSRFToken will use the following script
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.security.xsrf.SimpleXsrfTokenGenerator def XSRFToken = ComponentAccessor.getComponent(SimpleXsrfTokenGenerator).generateToken()
In the email body will use that token in the URL. So that url will be something like
def actionLink = "${baseUrl}/secure/WorkflowUIDispatcher.jspa?id=${issueId}&action=${action.id}&atl_token=${XSRFToken}" "<a class='aui-button' href='${actionLink}'>${action.name}</a>"
where I will write the script which generates the XSRFToken and how I will pass the XSRFToken to the email body?