- Follow the instructions on the main README file in the root directory of this repository.
- Create a Twitter Developer account.
- Replace the value of projectId in the server.js file with your Dialogflow agent’s Project ID.
- Log in to your Twitter Developer account and proceed to the Twitter App Management Console by clicking on your username to open the dropdown menu and then clicking on "Apps".
- Click on the "Create New App" button.
- Fill out the required fields and click "Create".
- In the Twitter App Management Console, click the "Details" button on the new project.
- Go to the "Permissions" tab and click the "Edit" button.
- Set "Access permission" to "Read, write and Direct Messages" and click "Save".
- Go to the "Keys and tokens" tab in your App details.
- Click "Create" under "Access token & access token secret".
- Take the values for API key, API secret key, Access token, and Access token secret and replace the values for twitterAPIKey, twitterSecretAPIKey, twitterAccessToken, and twitterSecretAccessToken in the server.js file respectively.
- Confirm that the "Access level" for the "Access token & access token secret" is "Read, write, and Direct Messages".
- Log in to your Twitter developer account and go to the Dev environments page by clicking on your username to open the dropdown menu and then clicking on "Dev environments".
- In the "Account Activity API / Sandbox" section, click the "Set up dev environment" button.
- Fill out the appropriate details and click "Complete setup".
- Take the value of Dev environment label and replace the value for environmentName in the server.js file.
In your local terminal, change the active directory to the repository’s root directory.
Run the following command to save the state of your repository into GCP Container Registry. Replace PROJECT-ID with your agent’s GCP Project ID.
gcloud builds submit --tag gcr.io/PROJECT-ID/dialogflow-twitter
Deploy your integration to Cloud Run using the following command. Replace PROJECT_ID
with your agent’s GCP project Id, and DIALOGFLOW_SERIVCE_ACCOUNT
with the Service Account which you acquired in the Service Account Setup step of the main README file.
gcloud beta run deploy --image gcr.io/PROJECT_ID/dialogflow-twitter --service-account DIALOGFLOW_SERVICE_ACCOUNT --memory 1Gi
- When prompted for a target platform, select a platform by entering the corresponding number (for example,
1
forCloud Run (fully managed)
). - When prompted for a region, select a region (for example,
us-central1
). - When prompted for a service name, hit Enter to accept the default.
- When prompted to allow unauthenticated invocations, press
y
. - Copy the URL given to you and use it according to the README file in the given integration's folder.
Take the value for the server URL printed in the console after the completion of the execution of the above command and replace the value for targetUrl in the server.js file.
Redeploy the integration with the updated change by rerunning the above two commands.
More information can be found in Cloud Run documentation.
You can view a list of your active integration deployments under Cloud Run in the GCP Console.
Twitter will block any duplicate tweets. So your Twitter bot may be prevented from retweeting a person if they are triggering the same response multiple times.
Cloud Run will return 504 errors after Twitter receives a message. Do not be concerned. These messages appear because of the way the Twitter integration returns messages, not because there are any actual issues.
Cloud Run will sometimes create multiple instances at startup due to a GET request from Twitter during the startup process. This will cause some delay to the startup process but will not cause any other issues.