broad-teacher-42540
05/30/2023, 8:37 PMacceptable-gold-88171
05/30/2023, 9:05 PMif (!event.state.session.fullHistory) {
event.state.session.fullHistory = ''
}
event.state.session.fullHistory = event.state.session.fullHistory + `user : ${event.payload.text}\nassistant : ${outgoingEvent.payload.text}` + '\n'
That will save the transcript to event.state.session.fullHistory
2. Then, in Explorer / Timeout, add an Execute Code card.
You'll need to call an email sending service
`
const SENDGRID_API_KEY = bot.sendgridApiKey // you have to set this up in sendGrid
const from_email = bot.sendEmailsFrom
const to_email = workflow.userEmail
const response = await axios.post(
'https://api.sendgrid.com/v3/mail/send',
{
personalizations: [
{
to: [
{
email: to_email
}
]
}
],
from: {
email: from_email
},
subject: 'Your conversation timed out. Here's the transcript',
content: [
{
type: 'text/plain',
value: event.state.session.fullHistory
}
]
},
{
headers: {
Authorization: 'Bearer ' + SENDGRID_API_KEY,
'Content-Type': 'application/json'
}
}
)
That's it. You'll have to ask for the user's email at the beginning and save it to userEmail (although you can change the variable names, so long as you adjust the code), configure the email in Sendgrid, and add it, and the sendgrid api key to the bot variables (in settings).acceptable-gold-88171
05/30/2023, 9:06 PMbroad-teacher-42540
05/30/2023, 9:09 PMbroad-teacher-42540
05/30/2023, 9:40 PMbroad-teacher-42540
05/30/2023, 9:40 PMacceptable-gold-88171
05/30/2023, 9:42 PMbroad-teacher-42540
05/30/2023, 9:43 PMhappy-easter-86380
09/21/2023, 5:54 PM