LinkLabs (ElizaOS+Functions)
  • Chainlink Workshop: Use AI agent to mint an NFT gift
    • Use an AI agent to interact with Blockchains
  • 1. Create table in Supabase
  • 2. Deploy the GetGift.sol
  • 3 Register A CL Functions Subscription
  • 4. Prepare DON hosted secrets
  • 5. Setup and start Eliza agent
  • 6. Use twitter client
Powered by GitBook
On this page
  • Where are we
  • Steps to use Twitter as client
  • What to do next?
Export as PDF

6. Use twitter client

Previous5. Setup and start Eliza agent

Last updated 3 months ago

Where are we

To allow users to interact with our Eliza Agent through a Twitter account, we create twitter client and register it with the agent (). To simplify things for this demo, the client logs in using your Twitter login details. You can tweet from your phone and ask for the gift, using your wallet account and a gift code. The AI Agent will read this tweet and reply to it and also trigger the GetGiftAction.

Steps to use Twitter as client

  1. Update the Agent's character file

In the file src/character.ts Specify that twitter is the client for AI agent to use as below.

...
clients: [Clients.TWITTER],
...
  1. Add Twitter credentials

Update the twitter credentials in .env file as below.

TWITTER_DRY_RUN=false
TWITTER_USERNAME= # Account username
TWITTER_PASSWORD= # Add your account password 
TWITTER_EMAIL= # Add your account email
TWITTER_POLL_INTERVAL=30 #seconds
  1. Start the agent again by command

pnpm start
  1. Check if the twitter account is running and posted first message. If it is working properly, you will see tweet like below. There will be a tweet posted if everything works.

  1. Post a new tweet to ask for a gift (make sure to tag the account's username!).

Don't reply in the same thread as your agent's tweet.

You can use any natural language to ask for a gift with gift code and your address on avalanche Fuji. In the tweet, you must provide wallet address and gift code in the tweet and don't forget to tag the AI agent account.

You can use any twitter account to post the tweet below because AI agent will listen all tagged tweets. It is also OK to share the gift code with your friends and give them the gift in this way.

  1. Check the responses

After the interval time, the AI agent will check the new tweet it is mentioned and make response. Usually, there will be 2 responses from the AI agent. The first message is the response directly from LLM and the second message is the details of actions triggered in AI agent.

Replied like below is generated by AI agent with LLM. the second one provides transaction hash to the user.

  1. Check the Chainlink Functions app

  1. Check if a NFT minted for a specific address

Go to the Opensea for testnet to check if you have a new NFT under the address on Avalanche Fuji. You may have the different gifts on your address. Also don't forget gift codes cannot be used twice.

What to do next?

The demo should not be used in production environment since some configurations are hardcoded and framework evolves in a very fast speed. Here are things you can do if you are interested in the field.

  • Modify the contracts to add more security check, eg. create a white list for multiple agents.

  • Make the AI agent to do more checks before sending transactions to blockchain, eg. check if the gift code is valid and only proceed the valid ones.

  • Do more prompt engineering to make AI Agent actions to make it more efficient.

  • Stay tuned with tech upgrade since to explore more things to do with the AI agent and Chainlink Functions.

Just as what we did with direct client. A transaction is sent to the Functions consumer smart contract. Then the request is displayed on .

Functions.app
repo reference
Use Twitter as client
This tweet is posted by AI agent
Post a new tweet to ask for a gift
Responses from AI agent
latest successful fulfillment to the request
A specific NFT is dropped to the address based on the gift ID in request