How to put a custom message in the message module template? I am using the Message module with Drupal 8 to log information.

I was able to get the date and time in the messages produced by adding a token of the date and time , but I want to add a customized message that is different each time.  How can I do this? this is the code I am using:

 $message = Message::create(['template' =&gt; 'sfbu_progress']);  
 $message-&gt;save();


How can I add a customized message to each message created?  For Example I want it to say "This file 444.pdf was successfully uploaded" or "this file 888.pdf was missing ".
Checkout the setArguments(), getText() and the processArguments() function in the Message Entity class:

$message = Message::create(['template' =&gt; 'sfbu_progress']);
$message-&gt;setArguments([
   '@my_argument' =&gt; 'my_argument_value',
]);
$message-&gt;save();


And in your Template which you create over the UI write the @my_argument to the textarea. It should be replaced with your text.

It is also possible to add an callback function as argument. Therefor checkout the declaration of the argument property in MessageTemplate Entity class.