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

Slackbot implement upload button/link in slack
Skype for Business Online - Send and Receive message using UCWA
Multiple users in bot framework
Don't let member to send message in telegram group
Connecting a bot to Microsoft Teams with dedicated API?
How do I parse string response in api.ai?
C# Bot Framework : Form flow set value for the field based on previous Answer [duplicate]
Connecting existing Slack RTM bots to new Microsoft bot framework back end after upgrade
Cancel a prompt or dialog after certain time - Bot Framework
How do I add a deep link to an app from my messenger bot?
How can I use the same bot on multiple facebook pages using bot framework
Why have I no callback query when i use URL in inline_keyboard?
Bot service with OAuth endpoint
What is the right way to measure time between bot's message and user's answer in the bot framework?
Telegram bot issue
Design custom entities for api.ai

Categories

HOME
orientdb
freeradius
out-of-memory
celery
google-sheets-query
share
repair
javafx-8
reportviewer
log4j2
siesta
tiff
smooks
powermock
nest-api
maven-plugin
nullreferenceexception
android-custom-view
anova
sipp
function-points
environment
web-push
python-appium
spreadsheetgear
ruby-daemons
toad
location-services
infopath2010
mongodb-3.4
xcrun
serversocket
cargo
django-crispy-forms
fastlane
slideshow
uipickerview
robust
vungle-ads
jshint
ipp-protocol
jenkins-slave
section508
cyanogenmod
webalizer
tinyioc
deployd
uiautomatorviewer
winston
solr-query-syntax
sequence-diagram
pen
patternlab.io
zend-server
hmmlearn
fitbit
system.web.optimization
nvda
dpkg
qtcpsocket
maven-release-plugin
unsigned
jeditable
polymerfire
mnesia
gridbaglayout
onepage-checkout
vim-plugin
wepay
perceptron
mousehover
sqlbase
css-paged-media
bootstrap-wysiwyg
htmltidy
symja
lumia-imaging-sdk
maven-central
senchatouch-2.4
accountmanager
iosched
lsa
vlab
sql-view
insertonsubmit
spark-view-engine
clearinterval
zotonic
kobold2d
fbml
zend-server-ce
server-variables
firefly-mv
space-partitioning
kohana-auth
3des
mongrel2
fxruby
subtext
downcasting
rakudo
efs
version-control-migration
suggestbox

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App