MSGToDocument
Convert Microsoft Outlook MSG files into documents your pipelines can query.
Basic Information
- Type:
haystack.components.converters.msg.MSGToDocument - Components it can connect with:
FileTypeRouter:MSGToDocumentcan receive MSG files fromFileTypeRouter.DocumentJoiner:MSGToDocumentcan send converted documents toDocumentJoiner. This is useful if you have other converters in your pipeline and want to join their output withMSGToDocument's output before sending it further down the pipeline.
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| sources | List[Union[str, Path, ByteStream]] | List of file paths or ByteStream objects to convert. | |
| meta | Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] | None | Optional metadata to attach to the Documents. This value can be either a list of dictionaries or a single dictionary. If it's a single dictionary, its content is added to the metadata of all produced Documents. If it's a list, the length of the list must match the number of sources, because the two lists will be zipped. If sources contains ByteStream objects, their meta will be added to the output Documents. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | List[Document] | Converted documents. | |
| attachments | List[ByteStream] | Created ByteStream objects from file attachments. |
Overview
MSGToDocument extracts email metadata (such as sender, recipients, CC, BCC, subject) and body content from MSG files and converts them into structured documents. Additionally, it extracts any file attachments from MSG files as ByteStream objects.
Usage Example
Initializing the Component
components:
MSGToDocument:
type: components.converters.msg.MSGToDocument
init_parameters:
Using the Component in an Index
This index converts MSG files to documents and sends them to DocumentJoiner that combines them with documents coming from other Converters. The joined documents are then sent to DocumentSplitter.
components:
FileTypeRouter:
type: haystack.components.routers.file_type_router.FileTypeRouter
init_parameters:
mime_types:
- text/text
- text/markdown
- application/vnd.ms-outlook
additional_mimetypes:
TextFileToDocument:
type: haystack.components.converters.txt.TextFileToDocument
init_parameters:
encoding: utf-8
store_full_path: false
MarkdownToDocument:
type: haystack.components.converters.markdown.MarkdownToDocument
init_parameters:
table_to_single_line: false
progress_bar: true
store_full_path: false
DocumentJoiner:
type: haystack.components.joiners.document_joiner.DocumentJoiner
init_parameters:
join_mode: concatenate
weights:
top_k:
sort_by_score: true
DocumentSplitter:
type: haystack.components.preprocessors.document_splitter.DocumentSplitter
init_parameters:
split_by: word
split_length: 200
split_overlap: 0
split_threshold: 0
splitting_function:
respect_sentence_boundary: false
language: en
use_split_rules: true
extend_abbreviations: true
DocumentWriter:
type: haystack.components.writers.document_writer.DocumentWriter
init_parameters:
policy: NONE
document_store:
type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
init_parameters:
hosts:
index: aga-index
max_chunk_bytes: 104857600
embedding_dim: 768
return_embedding: false
method:
mappings:
settings:
create_index: true
http_auth:
use_ssl:
verify_certs:
timeout:
MSGToDocument:
type: haystack.components.converters.msg.MSGToDocument
init_parameters:
store_full_path: false
connections:
- sender: FileTypeRouter.text/text
receiver: TextFileToDocument.sources
- sender: FileTypeRouter.text/markdown
receiver: MarkdownToDocument.sources
- sender: TextFileToDocument.documents
receiver: DocumentJoiner.documents
- sender: MarkdownToDocument.documents
receiver: DocumentJoiner.documents
- sender: DocumentJoiner.documents
receiver: DocumentSplitter.documents
- sender: DocumentSplitter.documents
receiver: DocumentWriter.documents
- sender: FileTypeRouter.application/vnd.ms-outlook
receiver: MSGToDocument.sources
- sender: MSGToDocument.documents
receiver: DocumentJoiner.documents
max_runs_per_component: 100
metadata: {}
inputs:
files:
- FileTypeRouter.sources
Parameters
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
| store_full_path | bool | False | If True, the full path of the file is stored in the metadata of the document. If False, only the file name is stored. |
Run Method Parameters
These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
| Parameter | Type | Default | Description |
|---|---|---|---|
| sources | List[Union[str, Path, ByteStream]] | List of file paths or ByteStream objects to convert. | |
| meta | Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] | None | Optional metadata to attach to the Documents. This value can be either a list of dictionaries or a single dictionary. If it's a single dictionary, its content is added to the metadata of all produced Documents. If it's a list, the length of the list must match the number of sources, because the two lists will be zipped. If sources contains ByteStream objects, their meta will be added to the output Documents. |
Was this page helpful?