You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

点击卡片跳转URL后,如何在Cortana中恢复原有会话?

Solutions to Restore Cortana Bot Session After External URL Redirect

Alright, let's tackle this Cortana bot session persistence issue you're facing. I've worked through similar scenarios with Microsoft bots on Cortana, so here are practical, actionable fixes to get users back to the exact conversation node after they return from an external URL:

1. Use Cortana Deep Linking to Pass Context

Cortana supports deep linking that lets you carry session context back to your bot when users return. Here's how to implement it:

  • When generating the adaptive card with the redirect URL, append critical session parameters (like a unique sessionId and currentConversationNode) to the external URL. For example:
    https://your-external-site.com?sessionId=xyz789&currentNode=product_inquiry
    
  • On your external page, add a "Return to Cortana" button that triggers a Cortana deep link. This link will send the saved context back to your bot:
    cortana://converse?botId=your-bot-unique-id&context={"sessionId":"xyz789","currentNode":"product_inquiry"}
    
  • Update your bot's backend to listen for this context payload. When received, fetch the corresponding session state (from your database or cache) and automatically resume the conversation at the currentNode.

2. Persist Session State Externally

Cortana's native session storage is limited, so offload your conversation state to a reliable external store (like Redis, Azure Cosmos DB, or your own backend database):

  • Before the user is redirected, save all critical session data—including conversation history, current node, user ID, and session ID—to your external store. You can do this via a quick API call from your bot:
    // Example: Save session state in Node.js
    await fetch('https://your-api.com/save-session', {
      method: 'POST',
      body: JSON.stringify({
        userId: turnContext.activity.from.id,
        sessionId: turnContext.activity.conversation.id,
        currentNode: 'product_inquiry',
        conversationHistory: turnContext.activity.history
      })
    });
    
  • When the user re-initiates the Cortana conversation, your bot should first check the external store for an active session tied to the user's ID. If found, load the saved state and jump directly back to the pre-redirect conversation node.

3. Add a Contextual "Resume" Command

Simplify the user workflow by adding a dedicated voice/text command to resume the previous conversation:

  • Train your bot to recognize phrases like "Resume my last conversation" or "Go back to where I was".
  • When the user triggers this command, have the bot query your external session store using the user's ID, pull up the most recent session state, and restore the conversation to the redirect point.
  • Proactively prompt users about this command on the redirect card: "After completing your task, say 'Resume conversation' to pick up right where you left off."

4. Embed a Lightweight Bot Component in the External Page

For a seamless experience, embed a mini-version of your bot directly in the external URL:

  • This embedded bot can sync user actions (like form submissions or selections) back to your main bot's session state in real time.
  • When the user returns to Cortana, the main bot already has the updated context and can resume the conversation without any extra steps from the user.
  • Note: This requires frontend integration (using the Bot Framework Web Chat component) and backend sync logic, so it's a bit more complex but delivers the smoothest user experience.

Key Notes to Remember

  • Always encrypt sensitive session data (like user IDs) when passing them via URLs or storing them externally to avoid security risks.
  • Test your solution across different Cortana platforms (mobile, desktop, smart speakers) since deep linking behavior can vary slightly.
  • Set a reasonable expiration time for saved session states (e.g., 24 hours) to clean up stale data and keep your store efficient.

内容的提问来源于stack exchange,提问作者Sash Sheen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 06:47:43