7

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

duffn
  • 3,690
  • 8
  • 33
  • 68
  • Can you try returning `"\\u20ac"` instead of `€` and see if it helps – Tarun Lalwani May 13 '18 at 17:56
  • @TarunLalwani This returns the characters "\u20ac" and the assistant reads it as "you twenty ack". – duffn May 15 '18 at 13:10
  • I think this may be a encoding issue then. I would look at the headers and make sure `Content-type: application/json; charset=utf-8` is being returned, if not then return the `content-type` header with the `charset` in your lambda. Another thing i would try is setting the content handling to convert to text if needed. I have not used it but not sure it would changing anything for you, https://i.stack.imgur.com/AMKTB.png – Tarun Lalwani May 15 '18 at 14:12
  • Did you get chance to try these things? – Tarun Lalwani May 19 '18 at 06:58

1 Answers1

3

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
burak
  • 3,839
  • 1
  • 15
  • 20
  • This returns exactly the same "â¬" characters. – duffn May 15 '18 at 13:09
  • I've tried this on my webhook and running. It's deployed to firebase. I checked both in my phone and on simulator. What are you seeing when you run console.log('\u20ac') at online editor: https://repl.it/repls/MelodicWillingFunction – burak May 15 '18 at 13:18
  • I see the Euro symbol in the online editor. Perhaps it is something with the way AWS is returning the payload? I am not using Firebase, but using AWS API Gateway and a Lambda function. – duffn May 15 '18 at 13:31
  • Maybe you can also try to use escape with ES6 way: \u{20ac} @duffn – burak Jun 01 '18 at 11:18