All Collections
Connect to pre-built integrations
Customer support data sources
Richpanel
Use Google App Scripts to import Richpanel data to Google Sheets
Use Google App Scripts to import Richpanel data to Google Sheets

Learn how to use a script to get data automatically from Richpanel into Google Sheets.

Updated over a week ago

You can use the Google App Script platform to get ticket data automatically from Richpanel into Google Sheets and then create a new Spreadsheets widget.

  1. Make a copy of this Google Sheet.

  2. Find your Richpanel API key.

  3. Navigate to Extensions > Apps Script.

  4. In the pop-up code window, enter your API key in two places by replacing the placeholder '<your-richpanel-api-key>'.

  5. Click the Save disk icon.

  6. Click on the Run icon to run the code block.

  7. Navigate back to your Spreadsheet and verify the 'Ticket Data' sheet tab is now populated with your Richpanel ticket data. We can now manipulate the data using queries and other functions for use in Geckoboard.

    For example, you could use the following array formula to display the number of tickets grouped by tag.

    =QUERY(ARRAYFORMULA(FLATTEN(IFERROR(TRIM(SPLIT(SUBSTITUTE('Ticket Data'!I2:I, ",,", ","), ",")), ""))), "SELECT Col1, COUNT(Col1) WHERE Col1 <> '' AND Col1 <> '#VALUE!' GROUP BY Col1 ORDER BY COUNT(Col1) DESC LABEL Col1 'Tag', COUNT(Col1) 'Number of Tickets'", 0) 
  8. When you're ready, switch to Geckoboard and connect your sheet using our Google Sheets data source.

  9. Once connected, you can build dashboard widgets from your Richpanel data. For guides to creating spreadsheet dashboard widgets, select from the following visualization types:

Script behaviour

The script fetches ticket data from the RichPanel API and updates the sheet tab 'Ticket Data'.

Notes:

  • If you're adding the script to another sheet, you must create a sheet tab with the same 'Ticket Data' name. If you use a different name, you must modify the script accordingly.

  • The script has a // ... add other fields as needed part. The total fields are available as part of this script, but the Richpanel API does offer more.

Script functions in detail

Function

Description

Notes

fetchAndPushToSheet

Fetches ticket data for the last 100 tickets from Richpanel's API from the list conversations endpoint.

  • Tags are returned with an alphanumeric ID, so a second call is made to get the corresponding tag names (human readable names) from their API.

  • For each ticket, it either updates an existing row or appends a new one in the 'Ticket data' sheet.

  • So, if a ticket ID already exists in the sheet but, say, the state went from 'New' to 'Closed', or a tag was added, or the customer replies, and it goes back to 'Open', etc., the script will modify the existing sheet row for that ticket ID and not create a new one. This handles changes/updates to tickets without incorrectly counting them as new tickets.

  • Only if a ticket ID doesn't exist in the sheet is a new row added with the ticket ID.

  • On each run, new changes will modify existing tickets or append the new tickets to the sheet, creating historical data.

fetchTags

Fetches tags from RichPanel and maps each tag ID to its name. This is part of the work explained above.

findRowByTicketId

Pinpoints the row in the sheet for a given ticket ID

Error handling

Errors are logged, but it won't interrupt the script.

Did this answer your question?