How to customize the name displayed with Slack bot messages - slack-api

LiveChat is a Slack bot that provides a chat widget for webpages which you can use to send messages to a Slack workspace. I would like to reproduce the behavior of the LiveChat bot which is somehow able to customize the bot name that appears with messages in Slack with a unique identifier for each user of the webpage with the chat widget.
I see that there is an as_user field in the Slack API, but LiveChat does not seem to be using this since clicking the name on any LiveChat message in Slack shows a popup for LiveChat. So the Slack user for all messages seems to be the LiveChat bot, but the name displayed with each message in Slack is customized as a unique id for the given user.
So, I don't want to dynamically control the user for each message. I just want to control the displayed name for each message from the single bot that I'm making.
I don't see anything in the postMessage API to support this. Do you know how to do it?
https://api.slack.com/methods/chat.postMessage

Related

Include message template created at facebook dashboard in Twilio to send message

I have created 2 message templates directly on the Facebook Dashboard(which are approved).
I have a Twilio WhatsApp Sender Account Already Linked to this number.
So my question is how do I enable these templates on Twilio so that I can directly send these template messages from Twilio send message API?
I don't think this is something you can do on your own. You can try to reach out to support and ask them to re-synchronize the template with your Meta Business Manager. That might be able to solve your problem.
My recommendation for the future is to create the templates in the Twilio console:
Access the WhatsApp Message Templates page in Console by navigating to Messaging -> Senders -> WhatsApp Templates.
Click the Submit a Message Template button. If you are not creating a template for the first time, you will see the New message template button. Click it to create additional templates.
Fill out the various fields of the template form, click Submit Message Template and the template will be sent to WhatsApp for approval. All templates must be approved by WhatsApp before you can use them for messaging users.

Slack API: Can I get all unread messages for a user?

I develop a mobile app Speaking Email that reads emails out to the user, which can be used while driving to work for example. I would like to add Slack as an account type. Ideally we would have Speaking Email read out the user’s slack messages that are unread, as these will be what they need to catch up on. However it does not appear the Slack API has a method for retrieving the messages the user hasn’t read. Is this possible with the latest Slack API?
I was searching for the same thing and found their API doc about Read Messages!
https://api.slack.com/messaging/retrieving

Integrate slack message menu with DialogFlow

I am working on a Chatbot for Slack with DialogFlow. I have put a message menu in Slack. I want to send the selected value to DialogFlow as an intent. It does not work.
Does DialogFlow supports message menus or Do I have to setup a webhook myself?
Thanks.
As #praveen suggested you will need to enable Fulfilment in DialogFlow settings for the project and point it to your fulfilment back-end service. After you have done that check Rich Messages Doc to see what data payload to respond with to DialogFlow from your Fulfilment service to make Slack display a menu.
UPDATE
If you want to perform an action in Slack and enable Slack notify you of that action then you can either user Slack RTM or Slack's event API

Show system messages in conversation history using iOS Twilio SDK

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.

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