California has signed legislation which bans the use of undeclared bots during elections.
Bots are automated online accounts which can be programmed to find and share information based around key words, themes or people.
The new rule also applies at all times to bots used for sales purposes unless they are very clear about their identity.
One expert warned it could prove difficult to enforce.
Russian-controlled bots were found to be very active on Twitter during the 2016 US presidential election, the firm has said.
They retweeted Donald Trump’s tweets 470,000 times, and Hillary Clinton’s fewer than 50,000 times, the social network told Congress earlier this year.
The new bill will come into force on 1 July 2019 after being signed by California governor Jerry Brown.
“This bill would, with certain exceptions, make it unlawful for any person to use a bot to communicate or interact with another person in California online with the intent to mislead the other person about its artificial identity for the purpose of knowingly deceiving the person about the content of the communication in order to incentivise a purchase or sale of goods or services in a commercial transaction or to influence a vote in an election,” the document reads.
“It’s a very useful rule but it might become an arms race – can you catch them?” said Prof Ralph Schroeder from the Oxford Internet Institute.
“They will have to decide whether to pursue someone, and at that stage it becomes difficult because bots are difficult to trace.
“It also raises further questions about whether there are also positive bots and they get caught up in all this.”
Twitter has also announced an update in its work on its “election integrity” project, ahead of the US mid-term elections in November.
These include updating its rules regarding fake accounts and sharing stolen information.
It said it would now take into account stock avatar photos and copied profile bios in determining whether an account is genuine.