Slack workspace bot to bot communication - api

i am trying to send messages through Amazon alexa via a bot-user to an already created chat bot that is within the workspace already.
after using webhooks i realised the chatbot does not recognize the messages i am posting through my bot-user.
my problem solving attempts included:
using the "as_user" method set as true. so messages are sent by the user but it seems to only visually change the name of the bot-user and my chat bot still does not respond to my messages.
is it even possible for a bot-user using slack web API to communicate to an App-bot that is within a channel on a workspace? I am using Postman to test. i suspect it has something to do with he scopes of the bot-user and the chatbot within the workspace just not being able to see the bot-user scope. This is all within the slack web api and this is how i am communicating with the workspace through the bot user.
see images to illustrate.
thanks alot hope you can help! :)
First image of postman:
second image of slack intentions:

Messages from real users look slightly different then message from bots / apps.
Apparently your chatbot is ignoring messages that are not coming form a real user. So the only way to "fix" that would be to modify the chatbot logic.
Example for message from real user:
{
"type": "message",
"user": "U12345467",
"text": "Good read for some of guys",
"ts": "1531745292.000021"
}
Example for a bot message:
{
"text": "Hey guys",
"bot_id": "B12345678",
"type": "message",
"subtype": "bot_message",
"ts": "1531700187.000049"
}

Related

Bad Request on HTTP.Post with Discord Bot

Greetings and thank you for tending to this question!
I am trying to have my Discord bot create a Scheduled Guild Event.
A Calendar event for players and attendees to join a voice channel.
I am trying to achieve that by doing a POST call to Discord's API, and I am failing with the following error.
The following message was produced from a Postman test.
{
"code": 50109,
"message": "The request body contains invalid JSON."
}
As the message implies something is off with my JSON body.
Below follows a version of the JSON body I am trying to send!
{
"name": "The Bot created this!!!",
"privacy_level": 2,
"scheduled_start_time": "2022-06-15T15:00:00+00:00",
"description": "The Bot also described this!!",
"channel_id": 980830611458426901,
"entity_type": 2
}
I tried to follow the API's documentation as perfect as I could with no positive results!!
If you wish to follow the documentation yourselves here's the link:
Create Guild Scheduled Event
I am definitely missing something or adding something that should be added to the JSON body
of a different type!!! Any insights welcome!
What I know and tried
My authentication is solid because I am able to GET all events present.
Many variations of single quotes '' and type declarations for the data in the JSON body.
Regardless of insights, Thank you for your time!!

Create stickerpack using only Telegram Bot Api (or telegram api)

The documentation describes methods for creating packs through api, but using them I constantly encounter various kinds of errors, mainly when sending images in a request. In general, maybe someone had experience in creating sticker packs through api, and maybe someone would like to share it)))
Update
Forgot to say that I use postman to learn api. Below is an example of a sticker file upload request:
request body
Headers
Request URI
https://api.telegram.org/botBOT_TOKEN/uploadStickerFile
And response that i get:
{
"ok": false,
"error_code": 413,
"description": "Request Entity Too Large"
}

Twilio WhatsApp username

I use Twilio [currently sandbox] for WhatsApp API.
I post to webhook when message is arrive to sandbox, I get data like this:
{"SmsMessageSid":"xxxxxxxxxx","NumMedia":"0","SmsSid":"xxxxxxxxxx","SmsStatus":"received","Body":"try1","To":"whatsapp:+14xxxxxxxxxx","NumSegments":"1","MessageSid":"xxxxxxxxxx","AccountSid":"xxxxxxxxxx","From":"whatsapp:+97xxxxxxxxxx","ApiVersion":"2010-04-01"}
Is there a way to get the username?
WhatsApp Facebook API does have a name in the payload:
{
"contacts": [ {
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "16315551234"
} ],
"messages":[{
"from": "16315551234",
"id": "ABGGFlA5FpafAgo6tHcNmNjXmuSf",
"timestamp": "1518694235",
"text": {
"body": "Hello this is an answer"
},
"type": "text"
}]
}
Source: https://developers.facebook.com/docs/whatsapp/api/webhooks/inbound
Talking to Twilio my team got the response bellow:
Twilio does not manage a user database. Although this is a data
variable on the WhatsApp API, we are not leveraging it immediately as
it is not mandatory from the WhatsApp docs and our data structure may
not fully support this yet.
Again the Beta Nature of the Product will unveil product needs and
features in which we have not moved forward with how or if we plan to
support this.
There is at least one provider that I know that has this feature.
For me looks like Twilio recycled all the architecture they have for SMS without any regret of any drawbacks. We just found one, the absence of WhatsApp username in the message payload.
I reached Twilio asking for a deadline for this feature but until now I didn't receive any news yet.
The From is the WhatsApp username, do you mean how to programmatically extract the username (and if so, is there a particular language you are using)?
"From":"whatsapp:+97xxxxxxxxxx
There is no username, all you will get is the number of the user that sent the message, which is the "From" value, unless the sender tells you its username through the message body.

Hangouts Chat: how to retrieve project_id or client_id in incoming event request?

I have setup a fully operational chat bot in Hangouts Chat orchestrated by a tailored webserver. I would like now to be able to have this webserver to interact with other Hangouts bots that I created and to route some requests to some of my other servers that will have to know which bots initiated the event.
With other provider, such as Slack, the app_id is provided in the event request data.
But with hangouts, this is not the case. I could not find any data in the request body or headers that represent either project_id or client_id.
In a more simple way my question is : "How to identify the Hangouts bot that send me an event request?" :)
An event request's response will contain an Event instance in its body, which one of its fields will be an User object. That User object will contain a name field that will represent the user's id (whether it's a human or a bot).
It will look like this:
{
"name": "users/<id>",
"displayName": "<name that appears in the chat>",
"type": "BOT"
}
One month later, I finally found the time to answer my question :)
In order to identify the Hangouts project that is calling your server, when you receive an event from Hangouts Chat, you'll find in the incoming request the header Authorization whose value is something like Bearer abcd1234.
If you decode this JWToken (ie, abcd1234 in our example), in the resulting data, you'll have a field aud which is exactly the "project number" of your Hangouts app. This "project number" can be found at "https://console.cloud.google.com/home/dashboard?project=referenceofyourprojecthere".

Sample of Instagram webhook notification data

I am currently doing an integration to the Instagram API and would like my app to receive webhook notifications whenever there is new media on any Instagram account which has authorized my app via OAuth.
I've been able to write the code which sets up my app to receive notifications using the instructions here. However, I noticed that the Instagram API docs contain no information on what the data in a change notification will look like. My searches online have also come back void. I need sample Instagram webhook notification data so I can write code to parse the data and apply it for my purposes.
I would have gone ahead to expose my localhost to the internet via ngrok, so Instagram would send data to my callback URL when I post a photo to my Instagram account. However, I discovered that the Instagram API does not allow you use an ngrok URL as a callback URL.
Now the only option I have is to deploy my partially completed code to an actual web server. Hoping someone else who has previously integrated to the API can share the format of the webhook notification data. I really don't want to have to do deploy my application at this point.
I eventually had to deploy my partially completed code to a web server. I put a logger behind my webhook callback URL to record the notification data sent to it by Instagram. Below is what it looks like:
[
{
"object": "user",
"object_id": "123456789",
"changed_aspect": "media",
"time": 1506338651,
"data": {
"media_id": "1611605324545559190_123456789"
},
"subscription_id": 0
}
]
The Instagram webhook notification payload/data is a JSON array of objects, each of which contains information on a single change to an Instagram account. Each JSON object contains the following fields:
object: A string whose value is always "user"
object_id: The ID of the Instagram account on which the subject change occurred
changed_aspect: A string whose value is always "media"
time: The Unix epoch indicating when the subject change occurred
subscription_id: The ID of the Instagram subscription object through which this notification was sent. A subscription object is created to ask Instagram to send webhook notifications to your app and is essentially a callback URL.
data: A JSON object containing the following fields:
media_id: The ID of the new Instagram media object (photo, video or carousel) whose creation triggered this webhook notification