Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actions on Google Node.js SDK unicode

How do I very simply show a Euro symbol in Google Assistant? Every time that I attempt to I get the symbol in a different encoding. What simple thing am I missing?

actions-on-google SDK version 2.0.1

const { dialogflow } = require('actions-on-google')

const app = dialogflow({ debug: true })

app.intent('euro-intent', (conv) => {
  console.log('€')
  conv.ask('€')
})

exports.myBot = app

My action is calling a webhook on AWS API Gateway that is connected to a Lambda function using Node.js v 8.10. The CloudWatch logs show

{
    "payload": {
        "google": {
            "expectUserResponse": true,
            "richResponse": {
                "items": [
                    {
                        "simpleResponse": {
                            "textToSpeech": "€"
                        }
                    }
                ]
            },
            "userStorage": "{\"data\":{}}"
        }
    },
    "outputContexts": [
        {
            "name": "projects/newagent-9bde7/agent/sessions/1525808242247/contexts/_actions_on_google",
            "lifespanCount": 99,
            "parameters": {
                "data": "{}"
            }
        }
    ]
}

However, I get the below in the simulator.

euro

like image 393
duffn Avatar asked May 08 '18 19:05

duffn


1 Answers

In your webhook, use unicode for EURO SIGN. The unicode for EURO SIGN is U+20AC

In your Node.js implementation, use '\u20ac' notation.

In a string value, '\u' notation indicates that value is a unicode character denoted by four hex digits.

Here is the version with unicode value:

const { dialogflow } = require('actions-on-google')

const app = dialogflow({ debug: true })

app.intent('euro-intent', (conv) => {
  console.log('\u20ac')
  conv.ask('\u20ac')
})

exports.myBot = app
like image 87
burak Avatar answered Sep 24 '22 17:09

burak