Search code examples
dasha

How Added dynamic data to phrasemap?


In my Dasha.ai code, I want to send dynamic variables to phrasemap.json. How can I send dynamic data to phrasemap if possible?


Solution

  • To dynamic phrase you should will do: In file "main.dsl" in context section create new variable (as example - "your_variable_phrase")

            context
        {
            input your_variable_phrase: string;
        }
    

    and then Dasha will say variable phrases for 2 ways:

    First. Use command "sayText" - to say something without phrasemap file. In section "do" #sayText($your_variable_phrase)

    Second. Use phrasemap. In the main.dsl in section "do"

        #say("greeting",
        {
            your_variable_phrase: $your_variable_phrase
        }
        );
    

    In phrasemap file:

     "greeting": {
        "first": [
          {
            "text": "Hello "},
          { "id": "your_variable_phrase", "type": "dynamic" }
        ],