How to get images from Google Sheets
In this article, you will learn how to get images from Google Sheets for your scripts so that the images don’t take up space in the script.
You specify images to be displayed on the screen, and you don’t need to add all these images to your script.
Add images to Google Sheets
For example, you have the following spreadsheet with fortunes:
Image URLs are located in the image
column.
.jpg
.Next, you need to publish the spreadsheet and get the URL to access it from the script. To do this, follow the instructions in the Read data from Google Sheets article.
Create a script
- Go to Tovie DialogStudio and create a new script.
- Add the HTTP request block in that part of the script where you want to get images.
- In the URL field, paste the URL that you received in the previous step.
- Add two Text blocks for the HTTP request’s outputs.
You will get the following script sample:
Add an Image block
-
Add the Image block to the
$prediction.line
screen and go to the Using link tab. -
In the Enter image URL field, write
$prediction.image
. -
Click Save. Now you can test your script.
Test the script
Click Test at the top of the page.
The bot will display an image that matches a random line received in the HTTP request.
Using the $prediction.image
variable, we specify the path to the image,
while the images themselves are stored in the spreadsheet and do not take up space in the script.