I'm creating a GroupMe bot that will serve to help me manage a few large groups which I'm the admin of. For now, I have decided to build a simple test bot using Javascript on a simple HTML page running on a local server just to get the basic functionality working. I've got most of what I want working, however the mentions feature is something that I still can't figure out. The relevant POST which sends the mentions message to the group is handled like so:
$.ajax({
url: botPostUrl,
type:"POST",
success: function(result){
console.log(result);
},
error: function(error){
console.log(`Error ${error}`);
},
data: {
"text" : messageContents + "\n" + mentionedMessageBlock,
"bot_id" : "my_bot_id",
"attachments": [
{
"type": "mentions",
"user_ids": [mentionedMembersUserIds],
"loci": [loci]
}
]
},
async: false
});
Where 'messageContents' is the actual message text that I want to send, and 'mentionedMessageBlock' contains all of the mentions. So ideally what I want to come up in GroupMe when I send this is something like: "Hey guys, please come to the meeting tonight! @User1 @User2 ..."
However, in its current state, this post just sends everything as a quote block of text, which means the actual mentions feature doesn't trigger and mentioned users do not actually get a notification.
This is where it gets weird: if I do a curl -d with the data part of the Ajax request and the bot's POST URL the same way as done above, the mention will work correctly. I cannot for the life of me figure out why it will work with cURL and not with Ajax, but maybe there is some simple fix or workaround for this out there.
Thanks so much for any help you're able to give!