# 3.4.6 Twitter

This section allows you to configure Twitter as a data source, and subsequently pull unstructured posts from specific Twitter hashtags.

For you to be able to pull tweets based on hashtags, you will need to set up your Ushahidi deployment as an application on Twitter. To get started,

* Click on ***the drop-down icon on the right as shown***

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2FJyfqfYGcg44TY8LEc1FE%2F3.4.23.png?alt=media&#x26;token=be5423c5-e326-4a06-9f53-27133e97c163" alt="Settings - Datasources: Button to open the Twitter datasource configuration"><figcaption><p>Settings - Datasources: Button to open the Twitter datasource configuration</p></figcaption></figure>

* Click on **Create a new Twitter application**. This will redirect you to <https://developer.twitter.com/en>

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2Ff5nVCvjCD63zw1OQlCXf%2F3.4.24.png?alt=media&#x26;token=39ddb5b9-a960-4798-b3d7-94274546efa7" alt="Twitter website: create a new twitter application."><figcaption><p>Twitter website: create a new twitter application.</p></figcaption></figure>

* Sign into <https://developer.twitter.com/en> using your Twitter username and password.
* Click on the **Developer Portal** to take you to the page where you will create your app or visit <https://developer.twitter.com/en/portal/dashboard>

<figure><img src="https://content.gitbook.com/content/GBEUb85x3qZ9AiwfCkhF/blobs/BSzLcigmWPfCL095K0Nw/Twitter_Developers.png" alt="Get your API Keys - Create an api key button highlighted "><figcaption><p>Get your API Keys - Create an api key button highlighted </p></figcaption></figure>

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2FcJ5Fxl9XK2vwCVj1OJnh%2F3.6.5.png?alt=media&#x26;token=dbb73e19-8497-4501-ac2e-6c5b95891459" alt=""><figcaption><p>Splashcreen for Subscriptions/Sign In/Developer Portal</p></figcaption></figure>

* Once you select the ***Developer Portal***, you will be directed to your portal immediately. If you haven't created a developer's profile yet, you will be redirected to sign up for one as shown in the picture below:

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2F5q8qOEDxyCbMcVcZ7Sew%2F3.6.6.png?alt=media&#x26;token=8701baa5-755e-4f44-b88f-5eecce6fbfeb" alt=""><figcaption><p>The page where the user signs up for a new Developer's Profile</p></figcaption></figure>

* From here, you can choose either to ***Sign up for Free Account*** or choose one of the paid tiers to subscribe to. Note that the free tier limits the feature sets offered in these other paid tiers. Check their website for more information: <https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api>
* Once you select the option ***Sign up for Free Account,*** you will need to describe your use cases and also agree to the terms and conditions stipulated.

<figure><img src="https://content.gitbook.com/content/GBEUb85x3qZ9AiwfCkhF/blobs/7FpVexEbQWO1X6aZtYG1/Twitter_Developers.png" alt="Apply for a twitter developer account"><figcaption><p>Apply for a twitter developer account</p></figcaption></figure>

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2FVbyYpIaxJFNcsFjMUmhj%2F3.6.7.png?alt=media&#x26;token=43347c32-c92b-4408-b989-83023c8cb312" alt=""><figcaption><p>Developer agreement and policy page</p></figcaption></figure>

* Once you have filled in your description and checked all the boxes, click **Submit.**

<figure><img src="https://content.gitbook.com/content/GBEUb85x3qZ9AiwfCkhF/blobs/0VtHlNgf5vXRkTI7O37x/Apply_%E2%80%94_Twitter_Developers.png" alt="Pick the reason you need the twitter developer tools for"><figcaption><p>Pick the reason you need the twitter developer tools for</p></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/GBEUb85x3qZ9AiwfCkhF/blobs/Jxl8hsQ6sHMbw1MA6rtw/Apply_%E2%80%94_Twitter_Developers.png" alt="Enter your details"><figcaption><p>Enter your details</p></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/GBEUb85x3qZ9AiwfCkhF/blobs/paQH6PV6KcbFPWwVm9wo/Apply_%E2%80%94_Twitter_Developers.png" alt="Get access to the Twitter API Page - Enter your intentions"><figcaption><p>Get access to the Twitter API Page - Enter your intentions</p></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/GBEUb85x3qZ9AiwfCkhF/blobs/jmlkZkk8ndkixeuZsgUp/Apply_%E2%80%94_Twitter_Developers.png" alt="Terms of Agreement"><figcaption><p>Terms of Agreement</p></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/GBEUb85x3qZ9AiwfCkhF/blobs/t8YktxdRBe4xAlNbAUrB/Apply_%E2%80%94_Twitter_Developers.png" alt="Submit ApplicationClick on developer agreements checkbox and then Submit Application button highlighted"><figcaption><p>Click on developer agreements checkbox and then Submit Application button highlighted</p></figcaption></figure>

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2Fqtz5XjmKLakeYuQGN6jL%2F3.6.8.png?alt=media&#x26;token=82c69951-0041-4cf2-8e0c-128c932fd4bc" alt=""><figcaption><p>Chechboxes and Submit button under the Developers Agreement and Policy</p></figcaption></figure>

* Once you click **Submit**, your developer account will automatically be created and you will be redirected to the Developer's Portal. Here, you will find out that Twitter/X has already created a project for you together with the app. You can proceed with this one, or you can delete the pre-made project and create yours afresh. If you decide to delete it, you can create a new one as shown below.

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2F5LUcPKDKJx6nBgX3zohY%2FScreenshot%202023-11-06%20171731.png?alt=media&#x26;token=45d7f4ab-b00e-40ac-af20-222c085420a6" alt=""><figcaption><p>The page where a user creates a new project</p></figcaption></figure>

* Once selected, you should give your project a name

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2FzL4hrSc03VYUUNj2e2ec%2F1.png?alt=media&#x26;token=1f246c12-1059-4d94-8d39-cc8d63bb7d8d" alt=""><figcaption><p>Describing the name of your project</p></figcaption></figure>

* Afterwards, select your use case for how you intend to use the platform

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2FulbiySC8Wsg7l5UDrICg%2F2.png?alt=media&#x26;token=5e891637-96db-449f-8347-de20aab47a31" alt=""><figcaption><p>Describing the use case for your project</p></figcaption></figure>

* Provide a brief description of your project

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2Fkf7hFio3M7vwgvkSbIJf%2F3.png?alt=media&#x26;token=0bf956db-e058-4199-95ca-75304b772f99" alt=""><figcaption><p>Describe the project that is being created</p></figcaption></figure>

* Once you are done, you should click ***Next*** to set up your app.

To set up your app in this project, follow the steps below;

* Select your App name.

You can enter the name of your deployment to make it more memorable.

<figure><img src="https://content.gitbook.com/content/GBEUb85x3qZ9AiwfCkhF/blobs/aoXdZ4hVdhWgJvdQVVbv/Twitter_Developers.png" alt="Twitter (X) Developer Page - Enter your App/Deployment/Project name"><figcaption><p>Twitter (X) Developer Page - Enter your App/Deployment/Project name</p></figcaption></figure>

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2Fe0NTO65MXtDCBN8ZYBAs%2F3.6.1.png?alt=media&#x26;token=5746bbe2-69cc-408e-934f-b5cbdb810c12" alt=""><figcaption><p>Enter your App/Deployment/Project name</p></figcaption></figure>

* Click on ***Next*** to generate your keys and toke&#x6E;***.***

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2FP6gvdErx1cgpHi2IcE4e%2F3.6.2.png?alt=media&#x26;token=bc7cf316-0585-455d-a15e-260ec36973ed" alt=""><figcaption><p>The page that displays your API Key, API Key Secret and Bearer Token</p></figcaption></figure>

* Here, you will see the **API Key, API Key Secret,** and the **Bearer Token** generated for your app. ***Make sure to master or note down these codes safely since you will use them when filling out the form in the Ushahidi Platform.*** These codes can be generated later on as we will see in the process down below. ***Keep in mind that regenerating these keys might need you to update your code for your app to work properly.***

***Note:** The API Key and Secret Key are treated like passwords, therefore they should be memorized or saved in a secure location. If the security has been compromised/you forgot to save the keys, new ones can be generated.*

### Test application configuration on Twitter.

* Go to ***Overview*** <https://developer.twitter.com/en/portal/projects-and-apps>, adjacent to your project app name, there is a Key icon, click on it to view your API and Access token keys. These will be needed to configure Twitter/X with your deployment.

<figure><img src="https://content.gitbook.com/content/GBEUb85x3qZ9AiwfCkhF/blobs/Gk3UF8smmAVPvGbrS2dF/Twitter_Developers.png" alt="The overview page on Projects and Apps - key icon is highlighted by a red arrow."><figcaption><p>The overview page on Projects and Apps</p></figcaption></figure>

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2FnMecVJ7asfmGIQ4zf00X%2F3.6.3.png?alt=media&#x26;token=1ac02db8-4f78-4690-a005-02479c6fc46b" alt=""><figcaption><p>The overview page on Projects and Apps</p></figcaption></figure>

* You’ll get redirected to a page where you can grab details needed to configure your Ushahidi deployment i.e CONSUMER KEY, CONSUMER SECRET, ACCESS TOKEN, ACCESS TOKEN SECRET.

<figure><img src="https://content.gitbook.com/content/GBEUb85x3qZ9AiwfCkhF/blobs/f198drflG26sDQ8Q4oDC/Twitter_Developers.png" alt="Grab your consumer access token &#x26; Secret and API key &#x26; Secret"><figcaption><p>Grab your consumer access token &#x26; Secret and API key &#x26; Secret</p></figcaption></figure>

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2F0UIJaoDMEVHjDCjTRDY3%2F3.6.4.png?alt=media&#x26;token=27c031da-93de-4a97-9137-de482658315a" alt=""><figcaption><p>Grab your consumer access token &#x26; Secret and API key &#x26; Secret</p></figcaption></figure>

* Go back to your Twitter configuration page on your deployment and fill in all the details from your Twitter app management page.

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2FKdjDT5slnMZF3yNHvF69%2F3.4.25.png?alt=media&#x26;token=68e55ef5-a030-4318-85ac-2f9b24e14cd9" alt="Configuration page for Twitter in Ushahidi Platform"><figcaption><p>Configuration page for Twitter in Ushahidi Platform</p></figcaption></figure>

* On your Twitter developer account panel, click on ***Reveal API Key hint*** next to **API key and Secret** to display a hint of your API Key. If you had not captured these codes before, you will be required to generate new ones. Copy and paste them on your deployment API and secret fields.&#x20;

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2FnauvkKNNMwGcjKg1Kb67%2FScreenshot%202023-11-06%20174653.png?alt=media&#x26;token=72df9c21-d9b9-4fbc-806d-4faa24a7df4e" alt=""><figcaption><p>Prompt that appears when you regenerate API Key and API Key Secret</p></figcaption></figure>

* On the same panel, you will see **Access Token and Secret**. You’ll have to generate an ACCESS TOKEN and ACCESS TOKEN SECRET by clicking on the ***Generate*** button.
* Copy and paste them on your deployment ACCESS TOKEN and ACCESS TOKEN SECRET fields.

***NB: if you save them without copying and pasting, you will be regenerating new ones.***

* Add the hashtags you want to pull tweets from in the ***Twitter Search Terms*** section. You can choose more than one hashtag, separated by a comma. It is recommended that short and clear hashtags be chosen.
* Click on ***Save*** and this data source’s settings will be saved. Unstructured posts from Twitter will now get pulled into the platform.

### Configure Twitter in the Ushahidi Platform

* To enable/disable the Twitter data source, simply click on the green toggle.
* If you’d like to edit your Twitter configuration, click on the Twitter option and make your changes. Once you are done click Save. You can also delete Twitter as a data source by selecting the delete button.

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2FrlLTwrM7KzSbtHfSAN9B%2FScreenshot%202023-11-06%20180209.png?alt=media&#x26;token=d04e668d-a896-4ebf-9791-27c6abafd9cc" alt=""><figcaption><p>Delete Option for Twitter Datasource</p></figcaption></figure>

You can also choose which survey you want to import the data source into and you can toggle the option of accepting survey submissions from this source.

<figure><img src="https://1490970077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGBEUb85x3qZ9AiwfCkhF%2Fuploads%2FLlsnRWR2pKmwbRZ3AwZ0%2F3.4.26.png?alt=media&#x26;token=e48ab2b3-4b97-4db3-8b7d-9561d367d331" alt="Enable the twitter toggle in the datasource to get tweets into platform"><figcaption><p>Enable the twitter toggle in the datasource to get tweets into platform</p></figcaption></figure>

It will only take a few minutes and the tweets will appear on your deploymen&#x74;**.**
