feat: Twitter Spaces Integration #1550
Merged
+1,306
−70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Risks
Low. Existing users who relied on Deepgram by default will still see no change unless they explicitly define a new
TRANSCRIPTION_PROVIDER
. Fallback logic preserves original behavior (Deepgram → OpenAI → Local).Background
What does this PR do?
TRANSCRIPTION_PROVIDER
setting (deepgram
,openai
, orlocal
) with fallback logic.agent-twitter-client
into this repo for better flexibility and less friction in plugin development.maxSpeakers
).Transcription Service Changes
TranscriptionProvider
enum (Deepgram
,OpenAI
, orLocal
) to replace string flags.initialize()
, the provider is chosen in this order:character.settings.transcription
(if the API keys exist),.env
(TRANSCRIPTION_PROVIDER
),character.json
, you can specify:DEEPGRAM_API_KEY
set, the service will use Deepgram; otherwise it continues to the next check.processQueue()
uses aswitch
onthis.transcriptionProvider
to pick the final method (transcribeWithDeepgram
,transcribeWithOpenAI
, ortranscribeLocally
).Flow Recap
Periodic Check
shouldLaunchSpace()
(random chance, business hours, cooldown).manageCurrentSpace()
handles speaker timeouts, occupancy updates, queue acceptance, etc.Space Creation
SpaceConfig
(topics from config or GPT).speakerRequest
,occupancyUpdate
,idleTimeout
, etc.Speaker Logic
activeSpeakers
array + a queue if at capacity (maxSpeakers
).speakerMaxDurationMs
per speaker.Stopping
stopSpace()
finalizes the Space, logs completion, clears states, etc.Configuration
A)
.env
/ Environment VariablesB)
character.json
→"twitterSpaces"
FieldmaxSpeakers
: number of concurrent speakers allowed.topics
: if none are provided, GPT generates them dynamically.randomChance
: probability for each check cycle to spawn a new Space.speakerMaxDurationMs
: maximum time each speaker can speak before removal.What kind of change is this?
Documentation changes needed?
Yes, minimal. We must mention:
TRANSCRIPTION_PROVIDER
in.env
(optional).twitterSpaces
config section incharacter.json
.Testing
Where should a reviewer start?
transcription.service.ts
to review how it resolves conflicts by prioritizing character settings, then.env
, then old fallback.Detailed testing steps
TRANSCRIPTION_PROVIDER
in.env
(or leave it empty to keep old fallback).deepgram
oropenai
.twitterSpaces.randomChance
in the character JSON to1
(for a 100% rate of starting a space).No special database migrations are needed. Basic local runs and logs confirm correct functioning.
Future Improvements