I'm trying to create a sms text notification that sends important emails to a persons phone as a text and displays that email message as a text. This is what I have but the problem I have is:
I will attach the code below ay help would appreciated.
function onGmailMessage(e) {
console.log(e);
// Get the ID of the message the user has open.
var messageId = e.gmail.messageId;
// Get an access token scoped to the current message and use it for GmailApp
// calls.
var accessToken = e.gmail.accessToken;
GmailApp.setCurrentMessageAccessToken(accessToken);
// Get the subject of the email.
var message = GmailApp.getMessageById(messageId);
var subject = message.getThread().getFirstMessageSubject();
// Remove labels and prefixes.
subject = subject
.replace(/^([rR][eE]|[fF][wW][dD])\:\s*/, '')
.replace(/^\[.*?\]\s*/, '');
// If neccessary, truncate the subject to fit in the image.
subject = truncate(subject);
return createCatCard(subject);
}
function onGmailCompose(e) {
console.log(e);
var header = CardService.newCardHeader()
.setTitle('Gmail SMS Alerts')
// Create text input for entering the phone number.
var input = CardService.newTextInput()
.setFieldName('text')
.setTitle('Enter Your Number')
var action = CardService.newAction()
.setFunctionName('onGmailInsertCat');
var button = CardService.newTextButton()
.setText('Send confirmation SMS')
.setOnClickAction(action)
.setTextButtonStyle(CardService.TextButtonStyle.FILLED);
var buttonSet = CardService.newButtonSet()
.addButton(button);
// Assemble the widgets and return the card.
var section = CardService.newCardSection()
.addWidget(input)
.addWidget(buttonSet);
var card = CardService.newCardBuilder()
.setHeader(header)
.addSection(section);
return card.build();
}