Skip to main content

Step 2 : Test the service locally

In this step, we will explore the process of running the Twitter Agent service locally, including testing its APIs to generate and retrieve access tokens and API keys.


1. Clone the agent service repo

git clone https://github.com/marlinprotocol/twitter-agent-service

2. Configuring the .env File

Inside the repo, create two environment variables files in your project's root directory and add the following environment variables

.env

USERNAME=                      # Username for the twitter account 
USER_EMAIL= # Email associated with the twitter account
X_APP_NAME= # Name of the application on X developer portal
KMS_ENDPOINT=http://kms_imitator:1100 #KMS imitator endpoint for testing locally, not required in production.
AGENT_HOST=0.0.0.0

.env.secrets

OPENAI_API_KEY=                # API key for OpenAI services  
USER_PASSWORD= # Password for the twitter account
USER_EMAIL_PASSWORD= # Password for the email account

Ensure that you correctly fill in the values for all required variables before proceeding.


3. Building and Running the Twitter-Agent & Verifier Locally

Step 1: Build the Docker Image

Before running the application, build the Docker image using the following command:

docker build -t twtagent .

Note : This command creates a Docker image named twtagent from the current directory.

Step 2: Start the Application Using Docker Compose

Run the following command to start the Twitter-Agent & Verifier using docker-compose:

docker-compose up --build

4. Generating Access Tokens and API Keys Inside the Enclave

Once the application is running, generate the required access tokens and API keys within the enclave by executing:

curl 127.0.0.1:8000/generate_keys_and_access_tokens

Note : This process can take 15-20 minutes

⚠️ WARNING: There is a significant risk of losing access to your Twitter and email accounts. Please proceed with caution!


5. Fetching Access Tokens and API Keys

After the keys and tokens have been generated, retrieve them using:

curl 127.0.0.1:8000/fetch_keys_and_tokens

Note : Sends a request to the enclave to fetch the previously generated keys and access tokens.


Conclusion

You have now successfully:
✅ Configured the .env file with the required environment variables.
✅ Built and started the Twitter-Agent & Verifier using Docker locally.
✅ Generated and retrieved access tokens and API keys inside the enclave.