im using slack to make chat bot so i can create a message center from my ios app to send message from ios app to slack.
getting following response from hitting joinChannel api https://slack.com/api/channels.join
cant get channel ids
{
"provided" : "admin,identify,chat:write:bot",
"ok" : false,
"needed" : "channels:write",
"error" : "missing_scope"
}
As the error message says you need the channels.write scope to use channels.join method.
Just add the missing scope to your access token and it will work.
Related
I'm trying to send a message to my self-Chat in Microsoft Teams through a Graph API call but can't find the ID of this specific chat. For the record, this type of chat was introduced to Teams in June, 2022.
By reading the Graph API documentation, it's possible to list all chats available for a specific user using the following API call (in this case, myself):
[GET] https://graph.microsoft.com/beta/me/chats/
Yet, I can't seem to find my self-chat in there. The chat itself is already created since I wrote messages in it but it doesn't appear in the call response.
I've tried to filter the results by most recent results, by filtering on my own name or by filtering by ChatType, but it was still missing.
Is anyone aware of a way to get the ID of a user self-chat in Microsoft Teams?
Thanks!
Self chat is a special kind, You can use this endpoint to communicate with it:
https://graph.microsoft.com/v1.0/me/chats/48:notes/messages
Hope that helps :)
Answering harrywyn's question regarding the pop up notification, you can set it as unread the same as any chat like this:
EndPoint = f'https://graph.microsoft.com/v1.0/chats/48:notes/markChatUnreadForUser'
update_chat = {
"user": {
"id" : uid,
"tenantId": TENANT_ID
}
}
resp = requests.post(EndPoint, headers=headers, verify=False, json=update_chat)
I am trying to build a calling app on slack that invokes a voip app installed on the computer. So when the slack app is given a particular command with a number it should invoke this desktop app and allow the user to make a call.
I have given the slack app calls:read
calls:write permissions but when i post a message from the service back to slack on response_url i am getting 500 error on slack.
slack_message = {
"response_type": "Call",
"call_initiation_url": "https://example.com",
"desktop_protocol_call_initiation_url": "sip:+15551231234?action=call"
}
header = {'Content-Type': 'application/json'}
response = requests.post(response_url, headers=header, data=json.dumps(slack_message))
Slack show 500 error.
However, posting back to response_url works when i post back a simple message, like shown below and i see it on the slack.
slack_message2 = {
"response_type": "in_channel",
"text": "It's 80 degrees right now."
}
Could some help in understanding what is going wrong ? I am stuck here.
I am developing a MSTeams application, and inside I use a messaging extension. Upon opening the extension, a request is fired over to my message handler, which I use an azure function to handle. Alongside the request is a payload, with details about the context (in this case the conversation or chat) of where the messaging extension was opened from.
Now, I've built up a graph URL with the conversation ID from the payload:
const id = context.req.body.conversation.id
const graphEndpoint = encodeURIComponent(`https://graph.microsoft.com/beta/me/chats/${id}/members`)
I authenticate a user by calling microsoftTeams.authentication.authenticate({...}) before I make the call, and use the token in the request.
Sometimes, this call will succeed, and return the information I want. However, the other times it will fail with a 400, telling me I had a bad request, despite it being a GET request with no body.
I notice in bad requests, that the conversation ID doesn't trail with #thread.v2 or #unq.gbl.spaces etc. I have no clue why this is so inconsistent, or if it's my fault. Any help would be appreciated.
EDIT: I have also seen that the issue only occurs when the id starts with a:, and succeeds when it starts with 19:. However, the context in which I open the messaging extension is the same each time: In a 1:1 / User:User chat.
I have previously implemented installing the bot in the conversation to get this information, but this method is very undesirable. Perhaps a side point - it seems that the conversations where I have previously installed the bot seem to return the 19: id, and everything else a:.
Here's an example of the 400 response:
{
"error": {
"code": "BadRequest",
"message": "Bad Request",
"innerError": {
"date": "2021-01-25T09:43:26",
"request-id": "3bb55aa2-e694-4c80-952c-88842f482dc1",
"client-request-id": "3bb55aa2-e694-4c80-952c-88842f482dc1"
}
}
}
The conversation id you received in the turn-context is not the chat-id. The conversation id is different from conversation id. Conversation id the id between bot and the user and chat id the id of the chat. Both are different. You cannot use conversation id to call the graph API. Please use the chat id to call graph API. You can get the chat id using list chats API.
I recently started using OneSignal to send notifications on my firebase based iOS project.
While I can send notifications to specific user and an array of users fine, I can't find documentation on how to set up OneSignal authentication with Firebase so that I can target a specific segment of users automatically through the app.
The code that I am using to send notifications to an array of users (working fine):
//to remove the current user ("playerID") from receiving notification
let indexToDelete = playerIDArray.index(of: playerID)
playerIDArray.remove(at: indexToDelete!)
var count = 0
while count < playerIDArray.count {
OneSignal.postNotification(["contents" : ["en" : "\(usersID!) has sent a message"], "include_player_ids" : ["\(playerIDArray[count])"]])
count = count+1
}
However, when I try to send the notification to a segments, like so:
OneSignal.postNotification(["contents" : ["en" : "\(usersID!) has sent a message"], "included_segments" : ["All"]])
I get this error:
2017-03-09 02:35:30.989 MyApp[3658:87978] ERROR: Create notification failed
I know that I am getting this error due to authorization issues, so I was wondering if anyone knows how to set up this authorization using Firebase?
Thanks so much!
you are actually getting this error because you cannot use "included_segments" as a targeting parameter from you app.
You can only use "include_player_ids".
Documentation here:
https://documentation.onesignal.com/docs/ios-native-sdk#section--postnotification-
If you would like to target segments of users, you may do so from your dashboard:
https://documentation.onesignal.com/docs/sending-notifications#section-selecting-users
or from the OneSignal REST API:
https://documentation.onesignal.com/v3.0/reference#section-send-to-segments
Overview:
I am working on a VB.NET application that places a call into Twilio, the number is not a test number. I am using the C# library with the code written in VB.Net.
When I use this line of code:
Console.WriteLine(account.SendSmsMessage(Caller, to1, strBody))
I receive a text message on my phone however the post back is never posted to my website. I have included the URL of the site on the account under Messaging > Request URL.
When I reply to the message, Twilio does make a post to my site. From what I understand, a POST should have been made when Twilio was first sent a message from my application, however this is not the case.
When using this code, I do not get any text message and no POST is made.
Console.WriteLine(account.SendMessage(Caller, to1, strBody, PostBackURL))
I have tried SendSMSMessage, I have tried it with the URL on my account and without it,
nothing seems to effect the behavior.
I need the SmsMessageSid at the time the message is sent. From everything I have seen, Twilio does not provide a response other then what is sent to the PostBackURL, I could parse a response for the
SmsMessageSid however since there is no response that is not an option. If I am mistaken on that point that would be great, however it looks like the only way to get a reply is with the post back URL. Thanks for your help with this! Below you will find an excerpt of the code I am working with:
PostBackURL = "http%3A%2F%2F173.111.111.110%3A8001/XMLResponse.aspx"
' Create Twilio REST account object using Twilio account ID and token
account = New Twilio.TwilioRestClient(SID, Token)
message = New Twilio.Message
Try
'WORKS
'Console.WriteLine(account.SendSmsMessage(Caller, to1, strBody))
'DOES NOT WORK
Console.WriteLine(account.SendMessage(Caller, to1, strBody, PostBackURL))
Catch e As Exception
Console.WriteLine("An error occurred: {0}", e.Message)
End Try
Console.WriteLine("Press any key to continue")
Console.ReadKey()
I'm doing something similar with C# and like you, I'm not getting the POST to the callback URL. I don't know why that's not working, but if all you need is the sid when you send the message, you should be able to do this:
message = SendSmsMessage(Caller, to1, strBody))
and message.Sid will give you what you need, assuming no exceptions.