bots


Override Context.PostAsync in the bot framework


I noticed that with the Bot Framework and Telegram channel, the smilies like :) aren't transform to an emoji.
Nevertheless, it very simple, we just need to change :) to :smile: and a nice emoji will appear.
The optimal solution would be to override the context.PostAsync() function, to perform those kind of string replacement, and then continue.
Can we override this method, without recompiling the all framework ?
Thanks :)
I assume that what you are looking is to change the message that the bot sends to the user.
Of course, the basic option is to just add the logic to check for the channel into your bot dialog and that's it. However, I suspect you want to reutilize that logic on other dialogs, which could also mean just a static method somewhere that allows you to do:
context.PostAsync(Utils.TransformMessage(message));
Now, if you really want to go with the cleanest approach, I think that should implement your own IMessageActivityMapper and register that into the Autofac container, so the MapToChannelData_BotToUser implementation ends up calling it (see here).
There are a few implementations of the IMessageActivityMapper here and here you can take a look at; though the interface is really simple and the whole idea is that you receives the IMessageActivity, update any of the existing properties (in your case it will be the Text property) and return the updated IMessageActivity so it can be posted to the user.
Once you have your implementation ready, you can register it in Autofac doing the following in your Global.asax.cs.
protected void Application_Start(object sender, EventArgs e)
{
{
// http://docs.autofac.org/en/latest/integration/webapi.html#quick-start
var builder = new ContainerBuilder();
// Register your mapper
builder
.RegisterType<MyActivityMapper>()
.AsImplementedInterfaces()
.SingleInstance();
// Get your HttpConfiguration.
var config = GlobalConfiguration.Configuration;
// Register your Web API controllers.
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
// Set the dependency resolver to be Autofac.
var container = builder.Build();
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
}
}

Related Links

Access Microsoft Bot Framework conversation history / logs
LUIS Portal Display Issue
How to make a bot respond/react to an incoming webhook message in slack?
Facebook Messenger Chatbot messages tagging (of sorts)
Slack bot send an image
Autoit pixel search inquiry
Can I install multiple bots on a single Facebook fanpage
How to get name, timezone, gender of your bot user in Messenger 1.4 API?
Bot becomes slow over time in loop
How to add discord bots the fastest way?
Microsoft Bot Framework - Proactive message, suspend current dialog
PromptDialog.Choice - Invalid Type Exception
Unknown CTA IDs in Facebook Analytics for Apps
Microsoft Bot Skype Group Chat
BotFramework sorry the service was upgraded and we need to start over
Best way to find moving function for a bot

Categories

HOME
python-2.7
xpath
office365
ionic2
cucumber
yahoo-weather-api
seedstack
barcode-scanner
d3.js
applescript
dry
openlayers-3
slider
odata
bing-search
elisp
hspi
msmq
azure-graph-api
game-maker
ex
bundler
trace32
pywinauto
android-custom-view
raima
points
acrobat
annotation-processing
cube
laravel-4.2
splunk-query
amazon-iam
locks
python-2.x
series
cucumber-junit
appcode
textmate2
landscape
variable-variables
viewcontroller
google-prediction
httphandler
dbcc
kitura
autorelease
ssi
sony-future-lab-n
amazon-elastic-beanstalk
winston
skip-lists
gtk#
android-mediarecorder
mobile-angular-ui
clrs
kendo-editor
dymola
google-shopping-api
nrf51
ternary-operator
metabase
system.web.optimization
dojo-build
groovyfx
powerpoint-2013
android-syncadapter
node-glob
persistent-object-store
vimperator
jsr363
in-app-billing
jnlp
modern.ie
subview
incron
operands
wicket-1.5
adwords-apiv201402
dmake
libgcc
osascript
xcode6.3.1
commenting
xulrunner
preorder
pre
apportable
blobstorage
sly-scroller
dibs
session-0-isolation
lynx
multiple-dispatch
series-40
net-use
representation
upshot
3des
printqueue
anonymous-types
ixmldomdocument
browser-based
dm
wmd-editor
watchpoint
community-server
rootkit
jvm-bytecode

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App