Show system messages in conversation history using iOS Twilio SDK - ios

Hi I have been working on one of my apps for integrating chat using Twilio SDK. I would want to know if it is possible to get the system message inside a channel for eg: 'Member A joined the channel', 'Member B left the channel', 'Member C accepted the invitation to join' and so on. It seems like Twilio SDK does not have API to get the system messages or to set them. How can we achieve this?
I also noticed that it can be achieved by setting the custom key-value pair in attributes inside the message and sending it to the channel. But for the newly invited members, they cannot send a message when they are declining the invitation request such as 'Member A declined the invitation to join channel', as they have not joined the channel yet.

Twilio developer evangelist here.
If you want to send persistent system level messages like this, you can do so with a combination of webhooks and the REST API.
The idea is that you can send messages to a channel using the REST API whenever you need one of these system messages. The default user for the REST API is the system and you can then treat messages from system as special for display in your UI.
I mention the webhooks because you can register to receive them for a number of useful events, like members joining and leaving channels. The webhooks may not cover all the things you want, like declining an invite, but for that I would just trigger my own HTTP request from the application to your server.
Let me know if that helps at all.

Related

How to initiate a 2 way SMS conversation between to validated phone numbers

We have the need to open an SMS conversion between clients and service providers. The thought is to send an initial request to the provider with a message from the client and then have the provider reply (and converse) directly with the client.
I've looked in the quick starts and the API docs but I don't see any clear pathway.
Am I missing some thing?
You can use a product like Twilio Conversations for that purpose. You add both as participants into a conversation. They communicate to each other via their assigned Twilio Proxy numbers.
Introducing Twilio Conversations: Now, every message becomes an invitation for a conversation
Using Twilio Conversations (Using Conversation You Tube Video - Signal 2019)

Posting to a teams channel from a logic app or flow which includes an banner alert / activity feed item

I have a logic app which posts a channel chat message to teams automatically when a new item is created in SharePoint. This I have working but our client requires that all the team members receive a banner alert and activity feed which I am having a lot of difficulty with.
What I've already tried...
Using a Incoming web hook on the teams channel - this was a very simple way to post from the logic app but the incoming webhook don't seem to support mentions.
Using the msft graph api - The /team/channel/message endpoint can post messages and user mentions but the this endpoint doesnt support channel or team mentions. It also appears that the graph API needs to use delegated permissions to post messages in teams. I'm using application permissions as this is a logic app. The logic app HTTP post connector doesnt offer the "connect as username#tenant.com" some of the other connectors use.
Using the flowbot post message - Like the above channel and team mentions are supported here so the post is added to the channel but with no notification to the team members
Using a notification only bot - I thought I nearly had it with this one. Microsoft's node bot sample number 57 looked like it can do most of what I want, it iterates through the users in the team and messages them this a customisable alert message...
https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/57.teams-conversation-bot
However I can't see how this bot can be triggered from my logic app as it seems to require an existing conversation context or an #mention from within teams to start communicating with users.
What I'm considering trying next
Iterating users within the logic app - Next I plan to try and get team membership from the graph API and iterate the members in the Logic App, posting a message to each user separately. I had hoped to utilise the group #mention feature as a simpler way so I'd be grateful if anyone had any thoughts on other ways of doing this, or maybe there's something wrong with what I've already tried that you could give me some expertise on.
Thanks in advance ;)
Andy
You're on the right track with the Bot, but you're wanting to send something called a "Pro-active" message. You need the bot registered in the channel in order to get access to a few key properties (conversation id, service url, etc.), but you can use those to send a message from -outside- your bot (e.g. in an Azure Function). You might be able to do this directly from a Logic App, but I haven't tested that specifically.
To find out more, see my answer at Programmatically sending a message to a bot in Microsoft Teams but I've also got a recent blog post that you might find interesting for background on this at How Bots Actually Work.
Hope that helps
You can use Graph to post a message in 1:1 chat as long as you have the chat it. You can find the answer in this post Send message to personal Chat via Graph API
You can also call Graph API from Logic Apps. (https://techcommunity.microsoft.com/t5/integrations-on-azure-blog/calling-graph-api-from-azure-logic-apps-using-delegated/ba-p/1997666#:~:text=Calling%20Graph%20API%20from%20Azure%20Logic%20Apps%20using,Manage%20-%3E%20Certificates%20%26%20secrets%20More%20items...%20)

How to receive contact name via Twilio WhatsApp

I am using the Twilio API for WhatsApp in a sandbox, for prototyping and testing. According to the Facebook / WhatsApp documentation, there are several types of inbound notifications that may be delivered to your unique Webhook.
Twilio API documentation is very limited and doesn’t mention any of the more advanced scenarios. For example retrieving the customers name, which should be present in every webhook request…
When I inspect the webhook, the body payload is very limited. Is there any way to receive the original channelData?
Apparently, this feature is not implemented yet. I received the following statement from Twilio.
Unfortunately we don't support the Contact name being included in the inbound Whatsapp message posted to your webhook at this time. I've raised a feature request for this with the Product Team in hopes that we'll have this feature available in the near future.
You can get the sender's name using the 'ProfileName' key from the request form.

How to make your bot user reply with a simple help message using slack bot

I have created a slack bot and I want to send a general static help message to users when they send a direct message to my bot:
Should I subscribe to Events API? Or do I need to do this in another way? I couldn't find a clear answer for this.
There are two ways to do make your bot user reply to direct messages:
Events API
Real Time Messaging API
In my opinion the Events API approach is easier to implement since it does not require using WebSockets.
The basic approach with the Events API is:
You need an endpoint that can receive event requests from Slack and
react to it, e.g. by sending a direct message back to a user.
Subscribe to message.im event for your bot user
Note that a bot user already has all the required scopes for this with the bot scope.
In addition I would recommend to subscribe to app.mention for your bot user. Then it can also react to mentions in other channels.
Btw. that message you posted looks a lot like a review comment from the Slack team for a new app submission. I got a similar one for my last app and I solved it with the approach above. In general it looks like if you want to have a bot user in your app it needs to be able to respond to help request from users.

Slack webhook and direct/private messages

I created a websocket-based Slack bot (that plays chess). In order to return a graphical representation of the board (so PNG instead of simple ASCII) I must use a webhook since normal messages cannot have attachments.
The interaction with the bot is through direct messages and I have 1 webhook. If I set the channel in the wehook to '#username' the message gets posted in that user 'slackbot' DM. But I want it to be posted in my bot's DM with that user.
How do I do that?
Or is there an alternative instead of a webhook?
Thanks.
Henry
Direct messages between bot and user
If you want to use a bot-specific direct message channel instead of the general slackbot channel you need to open a direct message channel just as you would between any two users.
Open the direct message channel from your bot to a user with im.open (which will provide you with the channel ID). Then send the message to that channel ID, e.g. with chat.postMessage.
Important: Make sure you use the bot access token and not the general access token for all API calls.
Method for sending messages
I would recommend using the API method chat.postMessage instead of the webhook. It gives you more options than a webhook and of course also supports attachments.

Resources