![]() ![]() Next step is to initialize the authentication and connect to Sheets:Īnd finally the code to perform the read, where we need to manage promises: ![]() The next section contains the fields of the API key that we have downloaded in the JSON file, and we only need 2 of them, the client_email and private_key, that you need to add to the code like this: In this snippet SheetDocument is the ID of the document that we found in its URL, and SheetName is the name of the Sheet, that defaults to Sheet1, but can be anything. Now you can build a new function that will perform the reading of a cell given a row and column: In the cloud function code (index.js) you also need to add the matching “require”: Edit your package.json and add the last line you can see here: You need to add a new library to your dependencies, as we are going to use the Google APIs to access Sheets. We are done with the setup, now let’s go for the code: The next step is granting permissions to the service account, so it can access the spreadsheet: Look for it on the top search bar and enable it: You also need to enable the Sheets API in the GCP project. Selecting that account you can create a new key using the JSON format, and it will be downloaded to your local device: You can create a new Service Account or use the one that should be already there for “Dialogflow Integrations”: To create the API key you have to go to the GCP console in the project that you use to run the Dialogflow agent, looking for the APIs and then Credentials menu. In this example I’m going to use the API key option, which is the easiest way, and also the less secure, as you have to write down that key in the fulfillment code. To access this document you need to authorize the API … there are 2 methods that are documented here. The ID is the bunch of characters after the /d/ : ![]() The first step is to create or identify an existing spreadsheet using its URL. If you use Google Sheets, there is an API that allows you to access data in spreadsheets, and we can access it from our agent’s fulfilment. For an education project I was asked to connect a Dialogflow virtual agent with a spreadsheet, so it contains information that we will provide to the users. Make sure to change the values of your Google login and spreadsheet name.Sometimes having an external database can be overwhelming in a small setup. Here is the code I created to get the From, Subject, and Spam Score of any email that goes to I created a quick Flask app with some functions to move around the spreadsheet. Next, make sure to create a Google Spreadsheet you want your data to be sent to. You can just pip install gspread or take a look at the other install options at the repo. Setting up the GSpread Module and Your Google Spreadsheet Make sure to check incoming email for spam so that we can get the spam score posted to our application. You can set the address of your application here. My domain in this case is Burrito.io, and I’m pointing to a URL where my app is located. Once the email flows through us, we will parse out the components ( ) of the email and post it a URL of your choice. This lets the registrar know that SendGrid will accept email messages on behalf of that domain. Then we tell SendGrid where to post the data from the email:Ĭhange the MX Records of your domain to point to mx. The first thing we need to do is tell your domain that SendGrid will handle the email on its behalf. In this post, I’ll show you one implementation on how to do this with the gspread module in Python. One of the questions I get asked a lot is how to get information from incoming emails entered into a Google Spreadsheet. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |