Technical Error on Reopening Chat in Virtual Agent for Custom Topic with REST Integration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Hi Community,
I'm encountering a technical issue with a custom Virtual Agent topic in ServiceNow named "XXXX". This topic includes REST API integrations and interacts with an LLM (Large Language Model) to generate real-time responses.
Working Process:
When a user initiates a chat and asks a question, the request is sent to an LLM model via REST integration. The model processes the input and sends back a response, which is displayed in the chat in real time. This part works smoothly during the initial interaction.
Issue:
The problem occurs when the user cancels the chat and then reopens it. Instead of starting a fresh conversation, the Virtual Agent throws a technical error. This issue is specific to the "XXXX" topic — other topics do not exhibit this behavior.
Summary:
- Topic Name: XXXX
- Includes: REST API calls + LLM integration
- Initial Chat: Works fine
- After Cancel & Reopen: Technical error appears
- Other Topics: No issues
Has anyone faced a similar issue or have insights into what might be causing this? Could it be related to session persistence, cleanup after REST calls, or something specific to LLM response handling?
Any help or suggestions would be greatly appreciated!
Thanks,
Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi @Aman Chaurasia ,
From your description, the issue is specific to the "XXXX" topic and occurs after cancelling and reopening the chat. This typically points to session or state management within the Virtual Agent topic rather than a core REST API or LLM integration problem.
Key Areas to Check
Session Cleanup:
When a user cancels the chat, Virtual Agent should clear the topic’s context and session data. If variables or temporary session data aren’t properly reset, reopening the topic may reuse stale data, causing errors.REST Integration State:
Review any REST calls or LLM integration logic that maintains temporary state tied to the chat session. Ensure these are reset or safely handled when the topic ends or is cancelled.Topic/Context Variables:
Check any topic or subtopic variables that persist across sessions. Improperly reset variables often cause errors when the topic is restarted.Topic Version / Publish Status:
Ensure the topic is published after all changes. Unpublished or outdated versions can lead to runtime errors.Error Logging:
Enable debug logging for the Virtual Agent topic and inspect system logs for errors related to VA session variables or API calls. Verbose logging on REST calls can help trace issues.
Recommended Fixes
Explicitly Reset Topic Context:
Use script steps to clear relevant context variables or call vaSystem.endConversation() to close the session properly.Restart Topic Fresh:
Use vaSystem.switchTopicById() to start a fresh instance rather than resuming the previous session.REST Call Handling:
Make sure REST calls handle cancellations gracefully and clean up any callbacks or promises.Republish Topic:
After changes, republish the topic to ensure the latest version is running.Review Logs and Exceptions:
Analyze Virtual Agent logs and Exception records to pinpoint root causes.
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.