How do I get the user message that a Slack Botkit hears? - slack-api

Using Botkit, how can I get the message from the user that triggered what a Botkit hears? For example, a user says "Hello, how are you" and the bot hears "hello" as the keyword. I do I get the entire "Hello, how are you"?

In case anyone else was wondering, you use message.text to access the message.

Related

Add buttons in whatsapp message response twilio

I currently have the following code which successfully replies any message I send with "Ola":
#app.route("/bot", methods=["POST"])
def bot():
incoming_msg = request.values.get('Body', '').lower()
resp = MessagingResponse()
msg = resp.message()
quote = 'Ola'
msg.body(quote)
return str(resp)
I would like to have response buttons to my reply. Please see attached image, I'd like to add the "Got it" button with my message text. Is that possible for python. Thanks.
To send quick reply or call to action buttons over WhatsApp using Twilio, you need to create a template and add the buttons to the template. To trigger the template, you need to send a message containing the text of the template in the body. This is all covered in more detail in the Twilio documentation on using buttons in WhatsApp.
Note, you need to have a working WhatsApp number in your account to create and send templates. You cannot use the Sandbox to test out this feature.

Twilio whatsapp message fails even when matches the approved template

I am trying to send a whatsapp message via Twilio Business Account, from a number my company has registered via twilio and configured to be a sender.
In the Twilio logs, I see error 63016 message not in template, even though I double-checked every word and spacing to see that my message matches the approved template
some code to help:
def send_message(phone, template_message):
try:
message = twilio_client.messages.create(
body=template_message,
from_=f'whatsapp:{MY_SENDER_NUMBER}',
to=f'whatsapp:{phone}'
)
except TwilioRestException as e:
return False, e.msg
return True, ''
this completes with no error and results in this log line in twilio
From,To,Body,Status,SentDate,ApiVersion,NumSegments,ErrorCode,AccountSid,Sid,Direction,Price,PriceUnit
"whatsapp:+XXXXXXXXXXXX","whatsapp:+XXXXXXXXXXXX","MY MESSAGE THAT MATCHES THE TEMPLATE,
WITH SOME NEWLINES!
AND some characters like '' and ,
",UNDELIVERED,2021-04-11T07:58:32Z,"2010-04-01",1,63016,XXXXXXXXXXXXXXXXXXXXXXXXXXXXx,XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx,"
outbound-api",0.0,USD
note: if I open my whatsapp and sends the sender a message, then if I run this code again it will work and I will see that message (as that message does not have to match a template for a 24-hr window).
After help from Twilio support, it was a missing '\n' in the message that I was trying to send, that caused the message not to match the template.
I had the same problem, but was due to just a simple whitespace.

How to customize error message on Siri intent response of type `failureRequiringAppLaunch`

I'm adding a Siri intent to my app for it to be used within the Shortcuts app. The user needs to be logged in in order to use the intent. When he is not, I send a failure completion with the code .failureRequiringAppLaunch.
For classic errors, ie not needing the app to be launched, I added a String property to customize the error message for the user.
Unfortunately, when I call the completion with the .failureRequiringAppLaunch code, the error message is not displayed, and the message "An unknown error occurred." is displayed to the user:
Here is my code:
let intentResponse = AllMeetingsIntentResponse(code: .failureRequiringAppLaunch, userActivity: nil)
intentResponse.failureReason = "You must log in to use this function."
return intentResponse
So if someone is able to tell me how I can customize the "app launch" alert, thanks in advance.
You can customize your error message by doing the following:
let response = AllMeetingsIntentResponse.failure(failureReason: "Fail because Bla bla bla")
completion(response)
I hope it helped you

StatusCallback does not work as expected

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.

how to share a link via sms in blackberry

I am building an application where I need the option to share via email and SMS.
I have done the share via Email, where when the user selects the image, the url is passed as the content of the email. But while sharing via SMS, I can't do something like setContent as I did for email and fetch the url in the SMS directly, instead of user typing the address manually.
I am using Message class in email and MessageConnection class for SMS, as shown in the blackberry community example.
The Message object you receive when calling MessageConnection.newMessage(TEXT_MESSAGE) is actually a TextMessage object (or a BinaryMessage object with BINARY_MESSAGE).
If you cast the received object to the proper class (TextMessage or BinaryMessage), you should be able to use its setPayloadText(String data) (or setPayloadData(byte[] data) for a BinaryMessage) to enter a value in the message before sending it.
Your code should look like this:
Message msg = myMessageConnection.newMessage(TEXT_MESSAGE, /* address */);
TextMessage txtMsg = (TextMessage)msg;
txtMsg.setPayloadText(/* Text to send */);
myMessageConnection.send(msg);
When you send an email, you can set the body of it and send it to the user from the Email native application. You cant do taht for SMSs. I worked on that issue and for BB Torch I was able to set the text of the SMS message but for other devices that was impossible. I always obtain an empty text message!!
So y suggestion to you is using the following code wich will send the SMS to a number without the interference of the user
MessageConnection conn = (MessageConnection) Connector.open("sms://" + userNumber);
TextMessage txtmessage = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE);
txtmessage.setPayloadText(text);
conn.send(txtmessage);

Resources