Best Practice to Allow Users to Upload Attachments During Incident Creation with AI Agent

MiftahF
Tera Contributor

Hi everyone,

I’m currently implementing an AI Agent to help users create incidents through chat. The agent asks a few clarification questions, drafts the incident details, and then creates the incident after user confirmation.

We would like to allow users to upload a screenshot or attachment during the process to help the support team better understand the issue.

What is the recommended approach to support attachment uploads during incident creation with an AI Agent?

  • Should the attachment be uploaded before the incident is created or after the record exists?
    Is there a recommended tool or prompt pattern to ask users for an optional screenshot during the conversation?

Any best practices or examples would be greatly appreciated.

Thank you.

1 REPLY 1

vaishali231
Tera Guru

hey @MiftahF 

The recommended and most maintainable approach is to upload attachments after the incident record is created.

 

 Why upload after record creation?

In ServiceNow, attachments are stored in the sys_attachment table and must be associated with:

  • a table name (e.g., incident)
  • a record sys_id

 Without an existing record, there is no reliable way to associate the attachment.

Benefits of post-creation upload:

  • Ensures proper linkage to the incident
  • Avoids orphan/temporary attachments
  • Keeps audit and data integrity intact
  • Simpler implementation (no temp storage or cleanup logic)

 

 Suggested Conversation Pattern (AI Agent)

Keep the experience optional and non-blocking.

Before creation (optional prompt):

Would you like to add a screenshot or file to help describe the issue? You can upload it after the incident is created.

After creation:

Your incident INCxxxx has been created. You can upload a screenshot or attachment here, and it will be linked to your incident.

 

 Implementation Options

1. Virtual Agent (Recommended if using VA)

  • Use Attachment input in the topic
  • Flow:
    1. Collect inputs
    2. Create Incident (Flow Designer)
    3. Prompt for attachment
    4. Attach to created record

 

2. AI Agent / Now Assist (Custom Implementation)

Use platform APIs or server-side scripts.

Option A: REST API

  • Endpoint: /api/now/attachment/file
  • Pass:

table_name = incident

table_sys_id = <incident_sys_id>

Option B: Server-side (Script Include / Action)

var gsa = new GlideSysAttachment();

gsa.write(current, fileName, contentType, fileContent);

 Best Practices

  •  Keep attachment optional (do not block submission)
  •  Restrict file types (e.g., PNG, JPG, PDF, TXT)
  •  Enforce size limits
  •  Provide upload confirmation to user
  •  Handle retry scenarios (failed uploads)
  •  Ensure correct table + sys_id mapping

 

 When to consider pre-upload?

Only in rare cases where:

  • Screenshot is mandatory before submission
  • You’re ready to manage:

temporary storage

reassociation logic

cleanup of unused files

Otherwise, avoid this pattern due to added complexity.


*************************************************************************************************************************************

If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh