Skype Bot sending message (not a reply) - rest

Trying to create a Skype Bot, but I have a problem. Please, help me.
I use PHP so I use REST (not NodeJS or C# SDK).
The task: I have to send data from html form on my website to Skype (so I don’t have to reply to a message, but just send).
Well, I have successfully create a bot in Microsoft Bot Framework.
Then I have successfully received an access_token.
Then they say in docs that I have to send a POST to:
/v3/conversations/{conversationId}/activities
According to https://learn.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-send-and-receive-messages I have to send a request to /v3/conversations with JSON like that:
{
"bot": {
"id": "12345678",
"name": "bot's name"
},
"isGroup": false,
"members": [
{
"id": "1234abcd",
"name": "recipient's name"
}
],
"topicName": "News Alert"
}
But what is the "member's id and member's name"?

To get the member ids of some members, add all those members in a group and add the bot, too, to the group and preferably send a message in the group, mentioning the bot. You will receive a json with a conversationId. With this conversationId, make a get request to v3/conversations/{conversationId}/members in order to receive the member-ids and member-names of the members in the group.
You can now proceed with these member-ids and member-names to start individual conversations with the members (which is illustrated in my answer to this question).

Related

How can I use marketing email templates with an API request?

I'm trying to set up an API request for Dynamics 365 to send an email template to a specific user, and I am having a lot of difficulty getting it to do what I want.
I'm using the SendEmailFromTemplate action and so far only have access to global templates. Whenever I try to use a marketing email template, it says it's not found. Is it even possible for me to use Marketing email templates with this action?
Response
"error": {
"code": "0x80040217",
"message": "template With Id = 41deb0fa-c108-eb11-a813-000d3a8c09cf Does Not Exist"
}
Additionally, I've not been able to embed user data in the global templates such as {{contact.address1_city}}.
Current request:
{
"TemplateId": "TEMPLATE-ID",
"Regarding": {
"contactid": "CONTACT-ID",
"#odata.type": "Microsoft.Dynamics.CRM.contact"
},
"Target": {
"regardingobjectid_contact#odata.bind": "/contacts(CONTACT-ID)",
"email_activity_parties": [{
"partyid_systemuser#odata.bind": "/systemusers(SYSTEMUSER-ID)",
"participationtypemask": 1
}, {
"partyid_contact#odata.bind": "/contacts(CONTACT-ID))",
"participationtypemask": 2
}],
"#odata.type": "Microsoft.Dynamics.CRM.email"
}
}
I might be going about it the wrong way. Any assistance is appreciated.
Thanks!
No this is not supported.
Marketing emails and CDS emails are two separate things - both business-wise and technically. Marketing emails are meant for sending emails in business to business and business to customer scenarios and are part of marketing solution. CDS emails are piece of core functionality.
If you do want to send marketing email your best shot is to use "quick send" instead.

How can I send a message to someone with my telegram bot using their Username

I am using the telepot python library, I know that you can send a message when you have someone's UserID(Which is a number).
I wanna know if it is possible to send a message to someone without having their UserID but only with their username(The one which starts with '#'), Also if there is a way to convert a username to a UserID.
Post one message from User to the Bot.
Open https://api.telegram.org/bot<Bot_token>/getUpdates page.
Find this message and navigate to the result->message->chat->id key.
Use this ID as the [chat_id] parameter to send personal messages to the User.
It is only possible to send messages to users whom have already used /start on your bot. When they start your bot, you can find update.message.from.user_id straight from the message they sent /start with, and you can find update.message.from.username using the same method.
In order to send a message to "#Username", you will need them to start your bot, and then store the username with the user_id. Then, you can input the username to find the correct user_id each time you want to send them a message.
You can't send message to users using their username that is in form of #username, you can just send messages to channel usernames which your bot is administrator of it. Telegram bot api uses chat_id identifier for sending messages. If you want to achieve chat_id of users, you can use telegram-cli, but it's not easy at all because that project is discontinued and you should debug it yourself.
in your case you should do following command:
> resolve_username vahid_mas
and the output will be something like this:
{
"user": {
"username": "Vahid_Mas",
"id": "$010000006459670b02c0c7fd66d44708",
"last_name": "",
"peer_type": "user",
"print_name": "Vahid",
"flags": 720897,
"peer_id": 191322468,
"first_name": "Vahid",
"phone": "xxxxxxx"
},
"online": false,
"event": "online-status",
"state": -1,
"when": "2017-01-22 17:43:16"
}
As the user you want to learn the ID of, send a message of any content to #JsonDumpBot. It will reply the whole JSON element that it receives from Telegram, including the ID of the user:
It's totally not safe to use other telegram versions available on internet, but I've seen that Telegram Plus has a ability to show you the chat_id of the user in their profile, even tho you don't have their contact.
Another way to extract chat_id of that particular user is that you have the phone number of that account, save it as your contact, then share it to this bot. It's easy to code it yourself but you can forward something from that user to this bot too, if you want to recieve the chat_id.
urmurmur has also mentioned another way. I haven't checked it yet but seems to be interesting.
Maybe you can try telethon:
from telethon import TelegramClient
def send_msg(name, msg):
with TelegramClient(session_file, app_id, app_hash, proxy=my_proxy) as client:
# client.loop.run_until_complete(client.send_message('me', 'hello')) # send 'hello' to saved messages
client.loop.run_until_complete(client.send_message(name, msg))
"name" can be "#xxxxx".
Then you can call send_msg(name, msg) in your bot.

setting event organizer with Outlook Calendar REST API

I am using the Outlook REST API for creating events and sending its invitations, based on this documentation
I authenticate the logged in user, and send its Bearer token through the Authorization header of the request, and the json-formatted event on its content.
If I set the "Organizer" to another user rather than the authenticated one, as well as the "IsOrganizer" property to "false", it gets totally ignored and sets the current logged in user as the organizer.
Any clues of what could be happening?
Is there another way of doing this?
Thank you!
I'm posting this in case someone else finds and needs an answer for this scenario...
You (Account A) can create a calendar event as someone else (Account B) through Office365 REST APIs as long as the account has permission to send as the other user account.
Here are the steps:
1) Call the Office365 REST API as follows,where {{{user2email}}} is the user you want the event to be created as (Account B's email address):
https://outlook.office365.com/api/v1.0/users/{{{user2email}}}/calendar
This should return Account B's user's calendar ID.
2) Pass in your JSON - the following is an example of what I used during unit testing:
{
"Subject": "Test - Created using Office365 Calendar REST API should be from Technology Notice",
"IsOrganizer": "False",
"Body": {
"ContentType": "HTML",
"Content": "This is where body copy goes HTML supported"
},
"Start": "2015-12-11T19:00:00Z",
"End": "2015-12-11T20:00:00Z",
"Attendees": [
{
"EmailAddress": {
"Address": "attendee1#yourcompany.com",
"Name": "Attendee One"
},
"Type": "Required"
}
],
"Organizer": {
"EmailAddress": {
"Address": "tnotice#yourcompany.com",
"Name": "Technology Notice"
}
}
}
'Technology Notice' will be who the calendar invite is from.
3) Use the ID from step 2 in your POST request, for example:
https://outlook.office365.com/api/v1.0/users/{{{user2email}}}/calendars/{{{ID}}}/events
Note: Make sure you're sending the POST request as the authenticated user account (Account A) who's account the mailbox/calendar it actually belongs to.
If everything is right you should be able to send a calendar invite and have it show up as originating from Account B instead of Account A.
Hope this helps someone out.
This is the correct behavior. You cannot create an event on User A's calendar but set the organizer to User B.

BOX API to invite external user

Just am trying to use BOX API for collaboration. i just wanted to know is there any REST api call available to invite a external user.
You just POST to https://api.box.com/2.0/collaborations with the proper auth header for your user that is authenticated (the person doing the invitation to collaborate). In the body of the request you would put the JSON to specify the folder and the invitee.
{"item": { "id": "12137", "type": "folder"}, "accessible_by": { "login": "rob#winterfell.com"}, "role": "editor"}
Then rob#winterfell.com will get an email telling them that they've been invited to see the appropriate folder.

Facebook: Link Request's sender to it's recipient?

When using the requests dialog, facebook issues a notification like this:
What I'm looking to achieve is for the user to click the request link shown above and to present a "Random User invited you to..." message on our App.
However, when clicking that link Facebook doesn't seem to pass through the id of "Random User" to the App. The url accessed by the link looks something like:
http://apps.facebook.com/randomcomp/?fb_source=notification&request_ids=350578327437399,350578327437399&ref=notif&app_request_type=user_to_user&notif_t=app_request
which doesn't contain any reference to the user who initiated the request.
From the App's side, there doesn't seem to be a way to get this information from Facebook. Sure, you can get a list of requests, but that list can contain information for many requests, including requests from other users in addition to the one we're interested in, so it's not useful in this case. For example, here's a snapshot of data:
{
"data": [
{
"id": "340083146057323_100003817986566",
"application": {
"name": "Random Competition",
"namespace": "randomcomp",
"id": "350578327437399"
},
"to": {
"name": "Hannah Smith",
"id": "100003817986566"
},
"from": {
"name": "Random User",
"id": "100002286042525"
},
"data": "100002286042525",
"message": "Use the app!",
"created_time": "2012-05-14T13:26:30+0000"
}, {
"id": "358318457550141_100003817986566",
"application": {
"name": "Random Competition",
"namespace": "randomcomp",
"id": "350578327437399"
},
"to": {
"name": "Hannah Smith",
"id": "100003817986566"
},
"from": {
"name": "Jane Young",
"id": "100003771838663"
},
"data": "100002286042525",
"message": "Use the app!",
"created_time": "2012-05-14T10:54:25+0000"
}],
}
}
As you can see, the data is being passed in, but there's still no way to join the click from the link mentioned above (for Random User) to the correct request in the list; the link passes through the ID for both requests, not just the one for Random User, and while the link states "Random User" it doesn't pass through an identifier.
Am I missing something? Is there a mechanism that isn't in the docs that will allow me to pick-up the "Random User" id so I can provide a nice "Random User invited you to..." message in the App when they click through?
Edit:
Turns out that this isn't possible - see my answer.
You can add some data to the request so that when you process the request you can differentiate that from other requests.
The data can be sent with app requests and users requests and the parameter name is "data".
For example, in the guide for the Requests Dialog you can see it in the properties table at the (almost) end of the document, it says:
Optional, additional data you may pass for tracking. This will be
stored as part of the request objects created. The maximum length is
255 characters
There's also some info about it in the Social Channels documentation, and a sample of (php) usage in the official blog post about Upgrade to Requests 2.0.
I hope that this is what you're looking for.
Edit
When you send the request you know who is sending it right? It's the logged in user, and so you can put the user id/name/etc in the data parameter of the request.
Then, when someone clicks on a request, get the request by the id that facebook passes to you, and from the data extract the user id of the sender.
As the documentation states, you have 255 characters to use, and with that you can do what ever you want, you can even serialize an object to that parameter and deserialize it later.
As it turns out, this is in fact not possible at all.
The link, as shown in the image below, can present multiple users:
which is why multiple request IDs are passed in, and the sender's ID isn't.