Reputation: 13
I've created an bot in C# that uses the Microsoft Bot Framework, and I'm trying to handle an inline query from a Telegram bot.
Since inline queries are channel-specific (telegram only) functionality, they are not supported right out of the box. The Bot Framework Documentation says the answerInlineQuery method is supported. This can be used to answer to an inline query.
My question is: How can I handle an inline query from telegram?
So far I've only used the OnMessageActivityAsync
function to handle incoming requests. This function does not get triggered once I start an inline query from telegram. Is there another function I can use to handle it?
Upvotes: 1
Views: 646
Reputation: 6383
When an activity is sent from Telegram to your bot, the associated data is contained within the ChannelData
property of the incoming activity. For example,
{
type: 'message',
id: '3451493078542633497',
timestamp: 2020-11-12T01:53:42.890Z,
serviceUrl: 'https://telegram.botframework.com/', channelId: 'telegram',
from: { id: '803***355', name: 'jdoe', role:
'user' },
conversation: { },
recipient: { id: 'SomeBot', name: 'SomeBotName' },
channelData: {
update_id: 424***655,
inline_query: {
id: '345*************497',
from: {
id: 803613355,
is_bot: false,
first_name: 'John',
last_name: 'Doe',
username: 'jdoe',
language_code: 'en'
}
},
query: 'how do you do?',
offset: ''
}
},
rawTimestamp: '2020-11-12T01:53:42.8907123Z',
callerId: 'urn:botframework:azure',
text: 'how do you do?'
}
All activities that contain relevant activity types (e.g. "message", as shown below) are able to be captured in the activity handler of the same name. If you are not seeing "activity" in OnMessageActivityAsync
, it is likely you don't have the handler configured correctly. As you haven't posted your activity handler code, it is impossible to say what the issue may be.
You can reference the BotBuilder-Samples for examples of how to set up your 'Bot'.cs file, located in the 'Bots' folders of every sample project.
Hope of help!
Upvotes: 0