Reputation: 348
I am writing a basic bot using botkit.js for facebook messenger. I need to be able to send a string of emojis. FB API just requires a UTF8 string. So I was able to get some emojis to work by wrapping the string in unescape. However, this doesn't work for all emojis.
unescape('I have been running for \u23F3' + uptime)
The above works fine, it will display the hour glass emoji. But if I try to use another emoji like the space invaders ship \u1F47E it does not work. All it displays is the E in the text.
Is there something I am missing here to get these to work, or is it just that I can only use a limited set of emojis?
Upvotes: 1
Views: 9767
Reputation: 697
I have found success by doing the following:
I think this works because the incoming message is in UTF8 format, so the emoji, though it will appear as an actual emoji in the log (😀) is in UTF8 format and can thus be sent via the api.
Upvotes: 4
Reputation: 348
My question was passed along to someone on the Facebook Messenger API team. The short answer is this. While facebook messenger supports the emoji's, the API does not. So while you can use them in normal chat, when you try to use them via the API they get stripped out. So currently, it is not possible because of that limitation.
Upvotes: 0
Reputation: 979
Check out the Facebook Emoji Codes, I think you could just paste the emojis to your string, below is my experiment for the sending API, I use the Postman to make a POST request with hourglass
and alien monster
emojis as messages.
{
recipient: {id: xxxxxxxx},
message: {text: "⌛"}
}
{
recipient: {id: xxxxxxxx},
message: {text: "👾"}
}
and this is what I got on Facebook, hope this would help :D
Upvotes: 3