# Twitter Response Gatherer

The FastStats Twitter Response Gatherer (FTRG) collects campaign responses from Twitter and stores them in the Social database, making them available in PeopleStage reports.

## Installation

The Twitter Response Gatherer installer is in the `DigitalIntegration.zip` file in the [Apteco Software Releases](<https://portal.apteco.com/software-releases>) area of the Apteco portal.

1. Extract `DigitalIntegration.zip` to the PC where you want the response gatherer to run.
2. Run `TwitterResponseGatherer64Setup.msi` and follow the installation wizard.

The default installation directory is `C:\Program Files\Apteco\FastStats Twitter Response Gatherer x64`. Install in your FastStats application files directory on the FastStats Application Server for the best results. The gatherer can also run on any PC in your system.

## Configuration

After installation, edit `TwitterResponseGatherer64.exe.config` in the installation directory to update the following settings:

- Connection string for the Social database (`SO_`)
- Connection string for the Control database (`WS_`)
- Bulk Insert directory

XML

```xml
<configuration>
  <add key="db_connection_twitter" value="Data Source=localhost;Initial Catalog=SO_AcmeInc;User Id=faststats_service;Password=N0tARealPassw0rd!;"/>
  <add key="db_connection_users" value="Data Source=localhost;Initial Catalog=WS_AcmeInc;User Id=faststats_service;Password=N0tARealPassw0rd!;"/>
  <add key="db_bulkinsert_directory" value="C:\FastStats\Publish\AcmeInc\bulkinserts\"/>
  <add key="db_connection_timeout" value="1200"/>
  <startup/>
</configuration>
```

> [!NOTE]
>
> Run Notepad as Administrator to save changes to files within `Program Files`.

## Running the Response Gatherer

You run the FTRG using Windows Task Scheduler and a batch file. Place the batch file and a `Logs` subdirectory in a folder called `FTRG` within the FastStats base directory. Create the `Logs` subdirectory manually before running the batch file for the first time.

[![FTRG directory](<https://help.apteco.com/assets/images/admin/integration/social/twitter/response-gatherer/FTRG.png>)](<https://help.apteco.com/assets/images/admin/integration/social/twitter/response-gatherer/FTRG.png>)

### Example batch file

Batchfile

```batch
REM - Twitter Response Integration
@echo off
cls
echo Twitter Response Integration
SET FTRG="%ProgramFiles%\Apteco\FastStats Twitter Response Gatherer x64\TwitterResponseGatherer64.exe"
SET LOGFILE="C:\FastStats\FTRG\Logs\AcmeIncTwitter.txt"
SET LOGFILEDETAILS="C:\FastStats\FTRG\Logs\AcmeIncTwitter_Details.txt"
echo. >> %LOGFILE%
echo. >> %LOGFILEDETAILS%
echo %date% %time% - Starting FastStats Twitter Response Download >> %LOGFILE%
echo %date% %time% - Starting FastStats Twitter Response Download >> %LOGFILEDETAILS%
echo. >> %LOGFILE%
echo. >> %LOGFILEDETAILS%
%FTRG% Administrator . AcmeInc "TIMEPERIOD=1W;APPLYANALYTICWINDOW=No" >> %LOGFILEDETAILS%
:OK
echo %date% %time% - FastStats Gathered Twitter Responses OK >> %LOGFILE%
goto Complete
:Complete
echo %date% %time% - Completed FastStats AcmeInc Twitter Response Download >> %LOGFILE%
```

| Parameter | Description |
| --- | --- |
| `SET FTRG` | Location and name of the FTRG executable |
| `SET LOGFILE` | Location and name of the log file |
| `SET LOGFILEDETAILS` | Location and name of the detailed log file |
| Argument 1 | FastStats system user: must have generated the Twitter Token |
| Argument 2 | FastStats user password: you can now use a single character |
| Argument 3 | System name |
| Argument 4 | Time to gather responses (e.g. `TIMEPERIOD=1W`, `TIMEPERIOD=1D`) |

## Scheduling with Windows Task Scheduler

In Windows Task Scheduler, create a task to run the FTRG as frequently as required.

[![FTRG Task Scheduler properties](<https://help.apteco.com/assets/images/admin/integration/social/FTRG_properties.png>)](<https://help.apteco.com/assets/images/admin/integration/social/FTRG_properties.png>)

[![FTRG Task Scheduler: local computer](<https://help.apteco.com/assets/images/admin/integration/social/twitter/response-gatherer/FTRG_properties_local_computer.png>)](<https://help.apteco.com/assets/images/admin/integration/social/twitter/response-gatherer/FTRG_properties_local_computer.png>)

Select the batch file you have created. Once the FTRG is running, responses are available in the PeopleStage Twitter Summary Report immediately.

[![Twitter campaign responses in PeopleStage](<https://help.apteco.com/assets/images/admin/integration/social/twitter/response-gatherer/Twitter_spring_blogs_campaign.png>)](<https://help.apteco.com/assets/images/admin/integration/social/twitter/response-gatherer/Twitter_spring_blogs_campaign.png>)
