@@ -166,6 +166,7 @@ func (s *pipelineService) startDebounce(ctx context.Context, event *model.Messag
166166 postbackURL : event .PostbackURL ,
167167 outgoingURL : event .OutgoingURL ,
168168 apiKey : event .ApiKey ,
169+ metadata : event .Metadata ,
169170 })
170171
171172 if err := s .debounce .Start (ctx , event .ContactID , event .ConversationID , event .MessageContent , event .BotConfig ); err != nil {
@@ -183,6 +184,7 @@ func (s *pipelineService) startDebounce(ctx context.Context, event *model.Messag
183184 PostbackURL : event .PostbackURL ,
184185 OutgoingURL : event .OutgoingURL ,
185186 ApiKey : event .ApiKey ,
187+ Metadata : event .Metadata ,
186188 }
187189 if err := s .repo .SetState (ctx , event .ContactID , event .ConversationID , newState ); err != nil {
188190 cancel ()
@@ -209,6 +211,7 @@ func (s *pipelineService) skipDebounce(ctx context.Context, event *model.Message
209211 postbackURL : event .PostbackURL ,
210212 outgoingURL : event .OutgoingURL ,
211213 apiKey : event .ApiKey ,
214+ metadata : event .Metadata ,
212215 })
213216
214217 // debounce.Start appends to buffer; DebounceTime=0 means no timer (Story 2.1).
@@ -340,13 +343,15 @@ func (s *pipelineService) runAIStage(ctx context.Context, contactID, conversatio
340343 )
341344 start := time .Now ()
342345
343- // Retrieve outgoing_url and api_key from the pipeline entry.
346+ // Retrieve outgoing_url, api_key and metadata from the pipeline entry.
344347 key := pairKey (contactID , conversationID )
345348 var outgoingURL , apiKey string
349+ var metadata map [string ]any
346350 if v , ok := s .entries .Load (key ); ok {
347351 if entry , ok := v .(pipelineEntry ); ok {
348352 outgoingURL = entry .outgoingURL
349353 apiKey = entry .apiKey
354+ metadata = entry .metadata
350355 }
351356 }
352357
@@ -356,6 +361,7 @@ func (s *pipelineService) runAIStage(ctx context.Context, contactID, conversatio
356361 ConversationID : conversationID ,
357362 ApiKey : apiKey ,
358363 Message : buffer ,
364+ Metadata : metadata ,
359365 })
360366 if err != nil {
361367 switch {
0 commit comments