Reputation: 39
Following this tutorial, I could create a new icon in Gmail compose UI which opens a Card, let's the user choose a photo, and inserts it into the email.
How can I directly insert the image once the icon is clicked on? This is going to be a frequent action and I don't want to require my user to deal with the UI every time. Is there any way to directly set a function returning newUpdateDraftBodyAction
in my composeTrigger.selectActions list?
Upvotes: 1
Views: 496
Reputation: 2760
To do this you have to understand how the click trigger the insertion of an image.
if you look at the tutorial you provided, there is a line responsible for the click action:
(...) CardService.newImage()
.setImageUrl(imageUrl)
.setOnClickAction(CardService.newAction()
.setFunctionName('applyInsertImageAction')
.setParameters({'url' : imageUrl})));
(...)
If we look into it a little closer we can see that we are telling our Images to have a OnClickAction
that calls a new action with the function name of 'applyInsertImageAction' and the parameters {"url":<imageUrl>}
.
So, in short, you have to call the applyInsertImageAction
function with the correct parameters to execute this action without the need for the extra clicks on the images.
Hope this helps!
Upvotes: 1