⚡ Add this skill
One command
Agent onboarding
Fetch this skill when a customer already uses Dify and wants its AI support agent to consume Autoplay live user activity.View the skill →
get_live_user_activity), and a user id wired through the agent’s input variables so the right user’s activity is always fetched.
🎬 End-to-end walkthrough
🔌 Add the Autoplay MCP server
In your Dify workspace, go to Tools (top navigation) → MCP tab → Add MCP Server (HTTP). In the modal that appears, fill in:- Server URL:
https://mcp.autoplay.ai/mcp - Name & Icon:
Autoplay live activity - Server Identifier:
autoplay-live-activity(lowercase letters, numbers, underscores, hyphens — up to 24 characters)
| Key | Value |
|---|---|
Authorization | Bearer YOUR_MCP_KEY |
get_live_user_activity.
🤖 Create an Agent app
In Studio, click Create from Blank → select Agent as the app type. Give it a name (e.g.Support Agent) and create it.
Inside the Agent’s Orchestrate view, find the Tools section and add get_live_user_activity from your Autoplay live activity MCP server. The tool’s parameters (product_id, user_id, limit) come from the MCP server definition — no manual configuration needed.
💬 Set the Agent instructions
The Instructions field (the system prompt) is where you tell the agent when to call the tool and how to use the activity data. Replace or append with:🔐 Identity — wire the user id into the agent
The agent needs the current user’s stable id to pass asuser_id to the MCP tool. In Dify, you do this with an input variable.
1. Add the input variable
In the Agent’s Orchestrate view, find Variables (or Inputs) and add:- Variable name:
user_id - Type: String
2. Reference it in the instructions
The{{user_id}} and {{product_id}} in the instructions above is how Dify substitutes the real value at runtime. The agent reads it and passes it as the user_id and product_id parameter when calling the tool. After that publish the agent.
3. Pass it when calling the Dify API
When your frontend calls the Dify API to start or continue a conversation, includeuser_id in the inputs object:
- PostHog
- Amplitude
inputs.user_id must exactly equal the id your activity source identifies the user with:
How the pieces fit: your frontend identifies the user
in your activity source → Autoplay stores activity under
that id → your frontend passes that same id as
inputs.user_id in the Dify API call → the agent reads
{{user_id}} from inputs and passes it to the MCP tool
→ the buckets match.✅ Test the full loop
- Log in to your app as a test user — fires your activity source’s identify call.
- Click around — visit a couple of pages, click a button, submit a form.
- Open the Agent (via your frontend or Dify’s Preview panel) passing the matching
user_idininputs. - Ask the agent: “What have I been doing in the app recently?”
- The agent calls
get_live_user_activityand answers with what you actually just did.
- 401 / Unauthorized → the
Authorizationheader is missing or the token is wrong — revisit Add the Autoplay MCP server above. - Empty activity returned → identity is working but that user has no recent activity yet. Browse around in your app first, then re-test.
- Wrong user’s activity → the
user_idininputsdoesn’t match the id your activity source uses. Check both are identical.
“No recent activity” = identity mismatch. Confirm the
same value in all three:
- the stable id your activity source identifies the user
with (PostHog:
posthog.identify(id), Amplitude:amplitude.setUserId(id)), - the
user_idpassed ininputswhen calling the Dify API, - the
{{user_id}}variable referenced in the agent instructions.
Next: Step 2 — Define proactive triggers