Manual setup: Botpress Studio hooks
1. Store your organization ID
Sign in to app.agnost.ai, open Settings, and copy the Organization ID. It is a UUID. In Botpress Studio, open Bot Settings, scroll to Configuration Variables, select +, and add a variable namedAGNOST_ORG_ID with your organization ID as the value.
2. Collect the bot’s replies
Open Hooks, select Create Hook, choose Before Outgoing, and name itagnost-collect-replies. Paste:
3. Send each turn to Agnost AI
Create another hook, choose After Turn End, and name itagnost-send-turn. Paste:
axios and env are available in every Studio hook, so no package install is needed. A failed request is logged and never interrupts the conversation.
Change botpress-bot to the name you want to see for this bot in Agnost AI. Publish the bot to apply the hooks.
Data mapping
event.conversationIdbecomes the Agnost AI conversation ID. Repeatingcapture-sessionon each turn is safe; Agnost AI keeps one conversation.event.userIdbecomes the user ID.event.preview, the plain text of the user’s message, is the event input.- The previews of all bot messages in the turn, joined with newlines, are the output. Buttons and cards appear as their text preview.
- Latency runs from the user’s message to the end of the turn.
- Botpress reports the turn’s AI spend in nanodollars. The hook converts it to USD as
cost_usd, which Agnost AI counts toward the conversation cost, and keepsbilled_tokensas metadata.
Why there is no SDK or OpenTelemetry section
Studio code cannot import external packages, so the Agnost AI SDK cannot run inside a hook. The hooks call the Capture Session and Capture Event API directly instead. Botpress Studio bots run in Botpress Cloud, and Studio has no setting to export OpenTelemetry traces to another backend.Verify
- Open the Studio emulator or your published webchat and send two messages in one conversation.
- Open Conversations in app.agnost.ai. The two messages appear as two events in one conversation.
- Open an event and confirm the input is your message, the output is the bot’s full reply, and the metadata includes
cost_usd.
Troubleshooting
- Nothing appears in Agnost AI: open the bot’s logs in Studio and look for
Agnost AI capture failed. A400meansAGNOST_ORG_IDis missing or not a UUID. - Requests succeed but no data appears: the organization ID is checked after the request is accepted, so a wrong but valid UUID returns
202. Copy it again from Settings in Agnost AI. - Outputs are empty: confirm the
agnost-collect-replieshook is a Before Outgoing hook and that both hooks are published. - The output includes the previous turn’s replies: the After Turn End hook failed before it cleared the session state. Check the bot’s logs for errors in that hook.
References
- Botpress hooks
- Botpress event properties
- Botpress configuration variables
- Using code in Studio (available libraries)
- Agnost AI Capture Event API
Next steps
- Conversations: review complete Botpress conversations.
- Events: inspect each user message and the bot’s reply.
- Patterns: organize production conversations by what users wanted.