owned this note
owned this note
Published
Linked with GitHub
## Twitter
Twitter is a social media platform that allows you to post tweets in the form of text messages, images, videos, and links.
Twitter integration helps in promoting your brand, create mentions related to customer queries.
In this article, you will learn:
* [How to create a Twitter account](#account)
* [How to setup a Twitter channel using the Developer portal](#developer)
* [How to connect a Twitter channel to your bot](#3-connect-line-channel-to-your-bot)
* [How to test your bot on Twitter channel](#test)
## 1. Create a Twitter account
1. Navigate to the [Twitter website](https://twitter.com/i/flow/signup) and click **Create account**.
2. Enter the required information, such as your name, email, date of birth, and click **Next**.
<img src="https://i.imgur.com/awiGWBi.png" alt="drawing" width="60%"/>
3. In the **Customize your experience** pop-up box, check the highlighted box to allow tracking your browsing history or uncheck the box to disable it. Click on **Next**.
<img src="https://i.imgur.com/lKczbUt.png" alt="drawing" width="60%"/>
4. Verify your information and click **Sign up**.
<img src="https://i.imgur.com/dwczCO8.png" alt="drawing" width="60%"/>
5. Enter the verification code that is sent to your email address and click **Next**.
:::note
If you used your phone number, you will receive a text with your code.
:::
<img src="https://i.imgur.com/Rb65bA4.png" alt="drawing" width="60%"/>
6. Enter a password and click **Next**.
<img src="https://i.imgur.com/Ad3L3zj.png" alt="drawing" width="60%"/>
7. You need to **Upload a profile picture** (optional) or click **Skip for now**.
<img src="https://i.imgur.com/OJVPh91.png" alt="drawing" width="60%"/>
8. Enter a username and click **Next**. You can also select the username, which is automatically generated by Twitter based on your information.
<img src="https://i.imgur.com/Dd9SUHU.png" alt="drawing" width="60%"/>
9. Click **Allow notifications** to receive notifications of your recent activities.
<img src="https://i.imgur.com/m4Wu0Zj.png" alt="drawing" width="60%"/>
10. Your Twitter account will be successfully created.

## 2. Setup Twitter channel using developer portal
To get the access token, access token secret, consumer key, and consumer secret, you need to connect to the developer portal. Use this [link](https://developer.twitter.com/en/apps).
#### Prerequisites
* Ensure that your phone number is verified.
* Ensure that your Twitter developer account is reviewed by the Twitter support team.
To setup a Twitter channel using the developer portal, follow these steps:
1. Login to the [developer portal](https://developer.twitter.com/en/apps) and click **+Create Project**.

2. Enter your project name and click **Next**.

3. Select a required use case and click **Next**.

4. Enter a description of your project and click **Next**.

5. Select the required app environment and click **Next**.

6. Enter your app name and click **Next**.

7. **API key** and **API key Secret** is generated. Click **App settings**.

8. You can view your app details and click **Set up** under "User authentication settings".
9. On the User authentication settings page, enable the following:
* Under **App permissions**, enable **Read and Write and Direct message permissions**.
* Under **Type of App**, enable **Web App, Automated App or Bot**.
* Under **App info**, enter the callback URL and the website URL.
* Click **Save**.

10. Upon enabling these permissions, a **Client ID** and **Client Secret** are generated.

11. Navigate to **Keys and Tokens**, regenerate **Consumer Keys** and **Access Token and Secret** and copy them to connect the Twitter channel to your bot.

12. To setup environment, under **Products** click **Twitter API V2**.

13. Select **Pro** pricing plan to interact with the bot.
:::note
* It is recommended to select either Pro or Enterprise plan to interact with the Yellow's bot.
:::

The following are the limits for pro plan:
Endpoint | Ratelimit
---------|----------
agent/bot messages | 1000 requests / 24 hours per user
agent/bot messages| 200 requests / 15 mins per user
## 3. Connect Twitter channel to your bot
To connect the Twitter channel to the Yellow.ai platform, follow these steps:
1. On the switcher, click **Channels > Social**.

2. Click **Connect**, to connect your bot to Twitter.

3. Enter the account details such as **Access token, Access token secret, Consumer key, and **Consumer secret**, that you have copied from the Twitters's developer portal. **Enable twitter mentions** to receive the events from the user and send them to the bot. A ticket has been created in the Inbox module so that a live agent can respond to the users, then click **Add account**.
<img src="https://i.imgur.com/AVpx2pt.png" alt="drawing" width="80%"/>
4. Your Twitter channel will be successfully connected.
## 4. Test your bot on Twitter
After configuring your Twitter developer account and connecting your bot to a Twitter channel, you need to test your bot.
To test your bot on Twitter, follow these steps:
1. Open your Twitter account and click **Messages**.

2. Use the search option to find your bot and start the conversation to test your bot.

3. Once you have tested your bot, the configuration of the Twitter channel for your business is complete.

## Twitter pricing plans
The following supported pricing plans for Twitter:
1. **Free Developer App**: This plan does not allow you to access the Direct Message (DM) lookup (get messages) or manage API (post messages).
2. **Basic Developer App**: This plan allows you to access both DM lookups and manage DM APIs with the following messaging limits:
* **Direct messages**: There is no limit on the number of direct messages that can be sent from Twitter to Yellow, but there is a limit on how many times you can look up or poll for new messages via the Twitter API. You can do that 5 times in 15 minutes and check for new messages every 3 minutes with this plan.
##### Limitaions
* Bot or agent can send 5 messages in 15 minutes
* Bot or agent can send 50 messages in 24 hours
* **Mentions**: Similar to direct messages, there is no limit on the number of mentioned tweets received at Yellow. There is a limit to how many times you can use the lookup API to fetch new tweets. And there is a limit of 10 request in 15 minutes for this plan, which means you can check for new mentions every 1.5 seconds, approximately.
##### Limitaions
* A bot or agent can reply or comment 100 messages in the mentioned tweets in 24 hours.
* **Pro Developer App**: This plan allows you to access both DM lookups and manage DM APIs with the following messaging limits:
* **Direct messages**: There is no limit on the number of direct messages that can be sent from Twitter to Yellow, but there is a limit on how many times you can look up or poll for new messages via the Twitter API. You can do that 100 times in 15 minutes and check for new messages every 10 seconds with this plan.
##### Limitaions
* Bot or agent can send 200 messages in 15 minutes
* Bot or agent can send 1000 messages in 24 hours
* **Mentions**: Similar to direct messages, there is no limit on the number of mention tweets received at Yellow. There will be a limit on how many times you can use the lookup API to fetch new tweets. There is a limit of 300 requests in 15 minutes for this plan, which means we can check for new mentions every 3 to 4 seconds.
##### Limitaions
* A bot or agent can reply or comment 100 messages in the mentioned tweets in 15 mins.
* A bot or agent can reply or comment 10000 messages in the mentioned tweets in 24 hours.