In the ninth class of the add-on development course for Google Workspace we are going to create an add-on that makes API requests outside of Google through Google Apps Script. Throughout the lesson we are going to modify our Gmail code that we did in previous lessons so that it allows us to insert content that we obtain through an API request with the Gmail Compose trigger. We will remove the insert date code we have and insert the new code in its place. To do this we will need to create an account on Giphy, Indian Email List a gif platform that allows us to use its own API to obtain a gif that we will insert into the email.
Let us begin! This content is only available to subscribers. You can identify yourself in this link or subscribe to the courses . That easy! I really like being able to make API requests like in Javascript and as you can see we can do very cool things with the appropriate APIs. As you can see, once we have the Giphy API key we can proceed to create the request with the UrlFetchApp object provided by Google Apps Script. This object will allow us to make requests of all kinds as if we were making a Javascript fetch request. We must bear in mind that the request response object will have to be parsed because we will not be able to use it directly. Here it comes into play to retrieve the JSON. Uae Phone Number parse () functions typical of Javascript that we can use directly to be able to convert the response json into an object with which we can work. Once we have this,
we will see how we can insert the image with an HTML tag into the email, passing the image variable as a parameter in the function associated with the button. This time I encourage you to investigate more about the integration with APIs to make an add-on a little more elaborate. For example, you could make an integration with an API such as Stripe or Streamtools to be able to link in some way the contextual information of some of the Google services and these third-party services. Remember that although it is easy to make requests, we have to parse the result and turn it into an understandable object for Apps Script. By the way! Don’t forget that if you have any questions or comments you can write to us through the support panel. 🙂