Attendee Satisfaction Survey Report Help Center January 13, 2023 16:34 Updated Index: Add new data to a Google spreadsheet via an API Create a survey flow in Builder Integrating Search Flow with Google Sheet End search flow NSTALLATIONS For the generation of this report, we will integrate it with Google Sheet. It will be necessary to make http requests and define variables in some steps of the flow. The generated data will automatically populate in the worksheet. Add new data to a Google spreadsheet via an API Activate the Sheet Service in your Project Create an Oauth token via client id and secret id and a google account to access google developer. Add Project. You need to go to the top left corner and click on your current project. A new window will open, at which point you will click on Create New Project in the upper right corner of this window. The following image shows the step by step. Give your project a name and save: 3º Activate the Token Service in your Project You need to go to the top left corner and click on ☰. With that, a new window will open on the left and at that point you will click on APIs and Services and then on Library. Now look for the word Sheets and select the first option. Now simply activate by clicking the button in the middle of the screen. This process will have to be repeated, but this time, click on ☰ and access APIs and services ➡ Dashboard In this new environment, click on OAuth Consent Screen that is in the left side menu and, in User Type , select External and click on CREATE. Then define a name for the API , enter the email for support and developers. At the bottom of the page, click SAVE AND CONTINUE. Then, on this next page that will appear, click on the same button at the bottom of the SAVE AND CONTINUE page. Do this until you reach step 4. In the fourth step, you must go to the end of the page and click on BACK TO PANEL , which will be the OAuth Consent. Then just go to PUBLISH APPLICATION, as in the image below: The status will change to "In production". 2nd step: Create Credentials On the left side menu, click on Credentials. On the page that opened, click on + CREATE CREDENTIALS and then the OAuth Client ID option Now select Web Application for the Application Type choice and enter the name of your choice. At this point you will need to pay close attention as it is an important part. Insert the following portal links into the Authorized Redirect URLs: https://www.portal.blip.ai/application https://developers.google.com/oauthplayground https://www.developers.google.com/oauthplayground Then click Create and move on to the keys, as in the tutorial shortly thereafter. At that moment, a window with the credentials will appear. Save all this information! 3rd step: Authorize Credentials The next step is to go to https://developers.google.com/oauthplayground and click on the gear in the upper right corner. In this new pop-up, enable the option Use your own OAuth credentials and fill in the data you collected in the previous step Finally, select the email to which the OAuth will be linked and click Allow. Then click on Token Exchange Authorization Code to get the refresh token. This will be used to refresh the access token as it expires every 60 minutes. Now just press CRTL+F to search for the word Sheets . Select the Google Sheets API v4 option to expand. Then, select the option that has the name spreadsheets, like the one in this figure After selecting, click Authorize APIs. If you ask to authorize accessing unknown domains, no problem: just proceed as usual. If this error occurs, click on the description that appears below the learn more and copy the warning url. Go back to slide 12 and follow the steps again. Under Exchange authorization code for tokens, you will have an authorization code. If tokens were not automatically generated, click Exchange authorization code for tokens. You'll need the Refresh token later on. So, already save this information 4th step: Create worksheet In this last step of integration with sheets you will need to create a spreadsheet in Google and name the columns. ATTENTION: if you do not name the columns, possibly, the integration will fail. Use at least one “temporary” name. With your spreadsheet in hand, you will need to store the code, which is the information after the /d/ and before /edit in the url. In our proposal, the spreadsheet will have the following columns: data | ticket | agent | time | score. You can include or exclude information as needed. Creating a survey flow in Builder Step 1: Create the flow For this flow, we need: Call completion block Research achievement block Justify Note block (optional) Review Thank You Block The final block should be right after the human service block. If you use a router and subbots structure, a flow can be used to capture the satisfaction survey, for example, the flow should follow this logic: 2nd step: Finishing block In the Finalization block, let's define the following variables: agent ticket team (you can use other names) Actions > Input Actions > Set Variable Each variable will have the following value: agent > {{input.content@agentIdentity}} ticket > {{input.content@sequentialId}} time > {{input.content@team}} Your variable name can be changed, but these values are Blip defaults. To ensure that the user goes to the next step of the flow (Satisfaction Survey), change the Standard Output to the Satisfaction Survey block. As a content suggestion for this block, we can put something like: Your service has been completed by the person who answered you, you're talking to me again, Joy! 😃 3rd step: Satisfaction Survey Block Click on the user's input and enable Save Answer to Variable and Validate User Input. Give your variable a name. Here, we'll call it score. We will put the following output conditions in this block: If the score is equal to or less than three, the user will go to the justification block. If the grade is equal to or greater than 4, it will go to the checking block (or any other finishing block you have). Integrating Search Flow with Google Sheet HTTP request Now, let's create two Output Actions in the Satisfaction Survey block of type HTTP Request. Let's do this to integrate our survey with Google Sheet. The first will be to authorize Google Sheet. We will use the POST method and the URL https://accounts.google.com/o/oauth2/token Empty Headers become empty. In the Save Response field, enter status1 and oauth. In the body of this request, we will place the following code: { "client_secret": "seu_id_secreto", "grant_type": "refresh_token", "refresh_token": "seu_refresh_token", "client_id": "seu_id_de_cliente"} Remembering that this information must be replaced according to the data that was generated in your credentials there in the Gloogle Cloud Platform: Your_secret_id, your_refresh_token and your_client_id. Changed the information, press ctrl + s to save. The next request is to integrate with the spreadsheet. In this same block, go back to Outbound Actions and select HTTP Request. Again, the method will be POST and, in the URL, you will place the following filled-in link: https://sheets.googleapis.com/v4/spreadsheets/{{codigo da sua planilha}}/values/{{nome da aba}}!{{colunas escolhidas}}:append?insertDataOption=INSERT_ROWS&responseDateTimeRenderOption=FORMATTED_STRING&valueInputOption=USER_ENTERED Example of completed link: https://sheets.googleapis.com/v4/spreadsheets/1nwvwDBddNRJoKe9P3OO6j4CO53c2JUyuzwgvTS1g2 qg/values/nota!A:C:append?insertDataOption=INSERT_ROWS&responseDateTimeRenderOption=FORMATTED_STRING&valueInputOption=USER_ENTERED In headers put KEY Authorization and Value Bearer {{oauth@access_token}} In the body, put the following code (or according to the variables you want to use): { "values": [ [ "{{calendar.datetime}}", "{{ticket}}", "{{agente}}", "{{time}}", "{{score}}"] ]} This {{calendar.datetime}} variable is the blip library's standard for recording timestamps. The variables must be inserted in the correct order according to the belonging column. In Save Response put status2 and responses Pay attention to the order of requests. The first must be to authorize, followed by the worksheet. Ending the search flow 1st step: Block to Justify Note Here, we will thank the evaluation and ask the user to explain the reason for their rating. You can record user input in an event log, direct it to human service, integrate with the spreadsheet… use your imagination! As an exit condition, we will direct the user to the Thank Justification block. Step 2: Thank the justification If the user leaves a message, we need to thank him for it. Then forward the user to the termination block. Remember to change the exit conditions according to the strategy you will adopt in your flow. Example of completed worksheet: Now just publish and test! 😀 For more information, visit the discussion on the subject inour community or the videos on our channel. 😃 Related articles How to create charts in a custom report How to integrate and send data from a bot to Dashbot? How to connect to a personalized service channel How to import a bot flow in Builder How to manage service queues in Blip Desk