# Custom Dialog

To use dialog (with sounds or text to speech) you need to use a MSFS devmode project. This project will contain the sound files (if you have them) and some files generated by the missionhub.

{% stepper %}
{% step %}

### Set up the Mission Package

Follow the instructions in [Mission Package](/miltech-mission-hub/developer-sdk/mission-package.md).
{% endstep %}

{% step %}

### Define the dialog in the mission hub

Now, you can go into the Mission Hub Scenario Editor.

Just place the *Custom Dialog* objects as you would any other mission hub object. You can give each *Custom Dialog* object a:

* *Dialog Text* (used for subtitles and text-to-speech)
* *Dialog Sound File* (name of the sound file without extension).

{% hint style="info" %}
To use text-to-speech, only define the *Dialog Text* and not the *Dialog Sound File*.
{% endhint %}
{% endstep %}

{% step %}

### Add Custom Script

To make sure the dialog will load during the mission, add a *Custom Script* object to your mission.

For the *Script Path*, set the path to your compiled dialog script:

`Missions\[CompanyName]\[MissionName]\customDialog.spb`
{% endstep %}

{% step %}

### Generate the dialog files

After you've placed your *Custom Dialog* objects, you need to generate the needed dialog files. Go to the advanced mission settings tab by selecting the *Advanced* tab on the top-left of the screen.

For *Dialog Package Name*, you need to fill in the package name of your devmode project.

Then, press the *Generate Dialog Files* button.
{% endstep %}

{% step %}

### Paste the generated files in the devmode project

To find the generated dialog files, go to the location of the scenario files (see [Sharing and Installing Missions](/miltech-mission-hub/guides/sharing-and-installing-missions.md)).

From the `SavedScenarioFiles` folder, go one level up to its parent folder.

In the parent folder, open the `CustomFiles` folder.

You will find two files:

* customDialog.xml (Msfs mission script file that contains the dialog logic)
* customDialog.loc (Localization file that contains the subtitles and links to the sound files)

You need to paste them in these folders inside your devmode project:

* customDialog.xml → `PackageSources/Dialog/`
* customDialog.loc → `PackageSources/Localization/`
  {% endstep %}

{% step %}

### Add your sound files (optional)

If you have sound files, add them to the `PackageSources/Dialog/Sound/en-US/` folder.
{% endstep %}

{% step %}

### Build the project

Build the devmode project.&#x20;

If you build the project **in-sim**, the files will automatically be loaded after the build is finished.

If you use the **fspackagetool**, you need to copy the built package to the community folder.
{% endstep %}

{% step %}

### Distribution

{% hint style="warning" %}
Make sure the package and mission folder names are changed from the example project. Otherwise it could lead to conflicting files with other missions.
{% endhint %}

You can distribute your dialog package by itself, but it would be more logical to distribute it as part of a [Mission Package](/miltech-mission-hub/developer-sdk/mission-package.md). In that case, you should create subfolders inside`PackageSources/Dialog/` and `PackageSources/Localization/` to avoid conflicts between the missions.
{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.miltechsimulations.com/miltech-mission-hub/developer-sdk/advanced-map-objects/custom-dialog.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
