Import email history
In short: Without history, aishaa sees every new email as a first contact. By importing recent emails, aishaa knows that a conversation has been going on for a while and what was discussed before. This is especially valuable in the first weeks after connecting; after that aishaa builds up new history by itself. There are three ways: straight after connecting Gmail, via the Google and Outlook management pages, or with a Google script for Gmail, for which you need an import key from the aishaa team.
Where to find this
- Straight after connecting Gmail: the Import recent emails page.
- For Gmail: Organisation > Channels > Mail > Manage Google (or Advanced settings > Providers > Manage Google).
- For Outlook: Organisation > Channels > Mail > Manage Outlook (or Advanced settings > Providers > Manage Outlook).
- For the Google script: outside aishaa, on script.google.com, with a script and an import key that you get from the aishaa team.
Who: from the Organisation admin role. An import applies per organisation and per mailbox.
What an import does and does not do
- aishaa fetches emails from the chosen period and places them as history with the right conversation. If the customer emails again later, your team and the AI agent see the earlier messages alongside.
- Imported history never changes the status of a ticket and does not reopen a closed ticket. It is background, not a new customer action.
- Duplicate messages are recognised and skipped. So you can safely run an import more than once; the summary then shows how many messages were imported and how many duplicates were skipped.
- An import only reads. Nothing is changed or deleted in your mailbox.
Method 1: straight after connecting Gmail
After signing in to Google you arrive on the Import recent emails page (This helps aishaa recognize existing conversations when customers email you again.) with the message Gmail connected.
- Under Days to import, choose a period: 7, 14, 30 or 90 days (default 30).
- Click Import. You see Import started. and the Import in progress block shows the progress. Until you have clicked, it says Start the import to see progress here.
- If you do not want to import any history, click Skip. You go back to Organisation > Channels > Mail. You can still import later via Manage Google.
The Import recent emails page straight after connecting Gmail, with the Gmail connected message, the Days to import dropdown and the Import and Skip buttons.
Method 2: via the Google or Outlook management page
Importing works the same way on both management pages:
- Under Lookback days, enter how many days back aishaa should look. Minimum 1, maximum 365, default 30.
- Click Import all (Google) or Import all mailbox bindings (Outlook) to import all connected mailboxes, or click Import next to a single mailbox.
- Follow the progress in the Import in progress block (Google) or Import running (Outlook).
With Outlook, the Import button for each mailbox is in the table below the Microsoft account. With Google, the Reconnect button appears instead of Import if access to the mailbox has expired; in that case reconnect first.
The progress block
| Item | Meaning |
|---|---|
| Status label top right | Running while the import is in progress, then the final status. |
| Line with provider and batch | Which provider and which import round you are following. |
| Progress bar | Fills up as soon as the total number of messages is known. |
| Progress text | Waiting for progress… at the start; then the number of processed messages and, once known, the total with Threads OK (processed conversations) and Failed. |
| Done | Appears when the import has finished, even if there were errors. |
Without an import in progress, it says No import running.
The Import in progress block on the Google management page, with the status label, the progress bar and the text showing processed messages, Threads OK and Failed.
The result
When it has finished you see a message: Import finished., Import finished with warnings. or Import failed. In the table on the management page, each mailbox shows the date of the last import with Imported and Skipped (Google) or the number of imported and skipped messages (Outlook). Failed imports show the error message in the Error column. On an imported ticket, the timeline shows a line with the number of historical emails imported.
Method 3: import Gmail with a Google script
This method is intended for Gmail mailboxes that you do not (or not yet) connect directly to aishaa, or for when you want to import more than 365 days back. You then run a script yourself in Google Apps Script that sends your emails to aishaa. For this you need the script and an import key. Contact the aishaa team via the aishaa support chat in aishaa (menu Chat, conversation aishaa support) or via support@aishaa.nl.
Setting up the import takes about five minutes:
- Go to script.google.com, signed in with the Google account of the support mailbox, and create a new script.
- Paste the script you received from the aishaa team into the editor.
- In the block with customer settings at the top, fill in only these values:
| Setting | Meaning |
|---|---|
IMPORT_KEY |
The import key you received from the aishaa team. |
LOOKBACK_DAYS |
How many days back you want to import, for example 21. You can also choose 7 or 14 if you prefer. |
FILTER_TO_ADDRESS |
Optional. Only fill this in if your Gmail inbox also contains personal email or other non-support email. Then enter your support address, for example support@yourcompany.com; aishaa then only imports conversations in which that address appears. If you use Gmail only for support, leave the field empty. |
- Save the script and click Run for the function runAishaaEmailImport.
- Give Google permission when asked. The script does the rest automatically.
If the script stops
With larger inboxes the script stops partway. That is normal: Google applies a time limit per run. Simply click Run again. The script remembers where it left off and continues automatically. You will not get duplicate tickets or messages.
Useful extra functions in the script
| Function | What it does |
|---|---|
| showAishaaImportStatus | Shows how far the import has got. |
| resetAishaaImportCursor | Restarts the import from the newest emails. |
Frequently asked questions about the script
- Is this safe? Yes. The script only reads emails and forwards them securely to aishaa. Nothing is changed or deleted in your Gmail.
- Can I run the script more than once? Yes, as often as you like. aishaa recognises duplicate messages and skips them.
- Do I need to do this again later? No. This is intended for the start. After that, new emails are processed automatically by aishaa through your connected mailbox or forwarding.
- Can I import fewer days? Yes. Change
LOOKBACK_DAYS.
Good to know
- Importing via aishaa is only possible for connected Gmail and Outlook mailboxes. For a mailbox that works through forwarding (own domain or SMTP) there is no import button; use the Google script instead (Gmail only) or contact the aishaa team.
- After connecting Outlook you are not taken to the Import recent emails page automatically. For Outlook, import via Manage Outlook.
- The maximum via the management pages is 365 days. The script does not have that limit, but Google limits how much the script can process per run.
- An import can take a while; you can leave the page in the meantime. You will see the final status later in the table on the management page.
- The script also has a
DRY_RUNsetting. If you set it totrue, the script only counts and logs, and nothing is sent to aishaa. Useful for checking how many emails there are in the chosen period.
