$(ai) Variable
Overview
The $(ai)
variable allows you to integrate AI into your StreamElements chat commands, generating dynamic responses based on user input. This powerful feature can enhance viewer engagement and create unique interactive experiences in your stream.
The $(ai)
variable is currently in beta and may be subject to changes.
Usage
To use the AI variable, include it in your commands with the following syntax:
$(ai *your_query_here*)
Replace *your_query_here*
with the text you want the AI to respond to.
Examples
-
Simple question:
!command add !aihelp ${ai How can I help improve the stream?}
-
Contextual response:
!command add !aifact ${ai You are a knowledgeable historian. Tell me an interesting fact about ${1:}}
-
Roleplaying:
!command add !aipirate ${ai You are a friendly pirate. Greet ${user} and tell them about your latest adventure.}
-
Combining with other variables:
!command add !aiwelcome ${ai Create a warm welcome message for ${1} who was last seen $(user.lastseen ${1}) ago. Their last message was $(user.lastmessage ${1}).}
Parameters
The $(ai)
variable accepts a single parameter:
query
: The input text for the AI to generate a response. This parameter is required.
Default Context
The AI variable comes with some default context that it's always aware of:
-
Channel Emotes: The AI knows about the custom emotes available in your channel. It can reference and use these emotes in its responses when appropriate.
-
Sender's Name: The AI is aware of the name of the user who triggered the command. This allows for personalized responses without explicitly including the user's name in the query.
-
Current Date: The AI knows the current date, allowing it to provide timely responses or reference current events when relevant.
This default context enables the AI to generate more relevant and personalized responses without requiring you to explicitly include this information in every query.
Configuration
Ratelimits
To prevent abuse, the $(ai)
variable has the following rate limits:
User Type | Requests | Reset Time |
---|---|---|
Regular | 3 | 60 seconds |
Affiliate | 10 | 60 seconds |
Partner | 30 | 60 seconds |
Best Practices
- Provide clear context in your queries to get more relevant responses.
- Use command cooldowns to prevent spam.
- Combine the
$(ai)
variable with other StreamElements variables for more dynamic interactions. - Test your AI commands thoroughly before using them in live streams.
FAQ
Q: Can I customize the AI's personality?
A: Yes, you can provide context or instructions in your query to shape the AI's response. For example:
$(ai You are a friendly pirate. Greet ${user} and share a sea shanty.)
Q: What happens if I don't provide a query?
A: If no query is provided, the variable will return an error. Always include a query when using the $(ai)
variable.
Q: Can I use the AI variable in combination with other variables?
A: Yes, you can combine the $(ai)
variable with other StreamElements variables to create more dynamic and personalized responses. See example 4 in the Examples section.
Q: Are there any content restrictions for AI-generated responses?
A: Yes, the AI is programmed to avoid generating inappropriate, offensive, or harmful content. However, it's always a good idea to monitor and moderate AI-generated responses during your stream.
Q: How long can my query be?
A: The query limit is 400 characters. For optimal performance, keep your queries concise. If you need a more extensive response, consider breaking it down into multiple separate commands.
Q: How can I report issues or unexpected behavior with the AI variable?
A: If you encounter any problems or unexpected responses, you can report them to StreamElements support or post in the official StreamElements Discord for assistance.
Troubleshooting
If you're experiencing issues with the $(ai)
variable, try the following:
- Check your rate limit usage and wait for the reset if necessary.
- Verify that your command syntax is correct.
- Ensure that your StreamElements bot has the necessary permissions in your chat.
- If problems persist, reach out to StreamElements support for further assistance.